<?PHP//The encoding of the set character is utf-8, which resolves the Chinese in the URLHeader("content-type:text/html; Charset=utf8 "); //get the variables in the browser URL$dbdatabase=$_get[dbdatabase];$tablename=$_get[TableName];//MySQL account password$dbhost= "localhost";$username= "Root";$userpass= "123456";//Connect to MySQL$link=mysql_connect($dbhost,$username,$userpass); if(!$link) { die(' Could not connect: '.Mysql_error());}Echo' Connected successfully ';Echo"<br>";mysql_select_db($dbdatabase,$link) or die(' Could not select Database. '));//MySQL Query statement$sql= "SELECT * from".$tablename;//MySQL INSERT statement$ins= "INSERT INTO".$tablename. "VALUES (' 5 ', ' thgf ', ' noon ', ', ', ')";//Execute INSERT statementmysql_query("Set Names UTF8");mysql_query($ins);//executes the execution statement to get the data in the databasemysql_query("Set Names UTF8");$result=mysql_query($sql,$link);Echo $result;Echo"<br>";//output What to look for while($row=Mysql_fetch_row($result)){ foreach($row as $val){ Echo‘--‘.$val; } Echo' <br/> '; } //4. Close Resources $row-Free (); Mysql_close();?>
How to access MySQL with PHP statements