Windows MySQL loaded SQLyog-32 bit
INSERT into USER VALUES (' 123 ', ' 123 ', ' Purple Xuan ');
Database query found to be garbled:
Probably because the default format for MySQL is latin1, it is recommended that you create a new database (which is not a reload) and change the encoding to GBK.
Fix MySQL garbled.
PHP connection MySQL
<?php $db _host= ' localhost '; $db _database= ' work '; $db _username= ' root '; $db _password= ' yubing '; $connection =mysql_connect ($db _host, $db _username, $db _password);//Connect to the database mysql_query ("Set names ' GBK '");//Code conversion if (!$ Connection) {Die ("could does connect to the Database:</br>". Mysql_error ());//Diagnostic connection Error} $DB _selecct=mysql_select _db ($db _database);//Select Database if (! $db _selecct) {die ("could not to the database</br>". Mysql_error ());} $query = "select * from user where username = ' $user _name '";//Build Query Statement $result =mysql_query ($query);//Execute Query if (! $result) { Die ("Could not to the database</br>". Mysql_error ()); }//Array mysql_fetch_row (resource $result); while ($result _row=mysql_fetch_row ($result))//Check out the result and display {$username = $result _row[0]; $password = $result _row[1]; $chname = $result _row[2]; echo "<tr>"; echo "<td> $username </td>"; echo "<tr>"; echo "<td> $password </td>"; echo "<tr>"; echo "<td> $chname </td>"; echo "<tr>"; echo "</tr>"; } mysql_close ($connection);//close Connection?>
Here's the mysql_query ("Set names GBK");
Note that MySQL and PHP code here to unify, the page display garbled solution
PHP MySQL Chinese garbled