This article is mainly on the PHP connection to MySQL 2 methods summary and to prevent garbled problems were introduced in detail, the need for friends can come to the reference, I hope to help you.
MySQL configuration error information for PHP: Class ' mysqli ' not found in answer:1. In Conf/php.ini, the vim uses "/php_mysql" to search for Extension=php_ Mysql.dll, remove the front ";" add extension=php_mysqli.dll at the same time below; Note that the rear DLL has an extra I 2. /extension_dir Check if the path is correct; 3. Find the ext/directory and put the Php_mysql.dll,php_mysqli.dll two files under Copy to%systemroot%/system32. 4. Restart Service Connection database code is as follows: //in Conf/php.ini, in vim with "/php_mysql" search to Extension=php_mysql.dll, remove the front of ";", At the same time add extension=php_mysqli.dll below; $mysqli = new Mysqli ("127.0.0.1", "username", "password", "library name"); $query = "SELECT * from form ORDER by theindex DESC"; $mysqli->query ("SET NAMES gb2312");/note this will not add garbled $result = $mysqli->query ($query); //printf () function output formatted string while (list ($name, $theindex) = $result->fetch_row ()) E Cho ("<br/>". $name. $theindex); $con = mysql_connect ("localhost", "username", "password"); if ($con) { mysql_query ("Set names ' gb2312"); mysql_select_db ("library name ", $con)//Note This will not add garbled &NBS P $rs = mysql_query ("Select * from form ORDER by theindex desc;", $con); if ($rs) { EC Ho ("<table border=1>"); &NB Sp while ($row = Mysql_fetch_assoc ($rs)) &N Bsp { & nbsp echo "< Tr> ". &N Bsp "<td> $row [theindex]</td>". &NB Sp "<td> $row [name]</td>". &NB Sp "</tr>"; &NB Sp } & nbsp mysql_free_result ($RS); } & nbsp echo ("</table>"); mysql_close ($con); }