MySQL Configuration for PHP
Error message: Class ' mysqli ' not found in
Answer:
1. In the Conf/php.ini, in vim with "/php_mysql" search to Extension=php_mysql.dll, remove the front of the ";",
At the same time add extension=php_mysqli.dll below;
Note that the back of the DLL is a little more I
2. "/extension_dir" Check whether the path is correct;
3. Locate the ext/directory and put the Php_mysql.dll,php_mysqli.dll two files under Copy to%systemroot%/system32.
4. Restart Service
Connecting to a database
Copy Code code as follows:
In the Conf/php.ini, in vim with "/php_mysql" search to Extension=php_mysql.dll, remove the front of the ";" At the same time add extension=php_mysqli.dll below;
$mysqli = new Mysqli ("127.0.0.1", "username", "password", "library name");
$query = "SELECT * from table ORDER by theindex DESC";
$mysqli->query ("SET NAMES gb2312");/note no garbled here
$result = $mysqli->query ($query);
printf () function output formatted string
while (list ($name, $theindex) = $result->fetch_row ())
Echo ("<br/>". $name. $theindex);
$con = mysql_connect ("localhost", "username", "password");
if ($con) {
mysql_query ("Set names ' gb2312 '");
mysql_select_db ("library name", $con);/Note no garbled here
$rs = mysql_query ("SELECT * from table order by theindex desc;", $con);
if ($rs) {
Echo ("<table border=1>");
while ($row = Mysql_fetch_assoc ($rs))
{
echo "<tr>".
"<td> $row [theindex]</td>".
"<td> $row [name]</td>".
"</tr>";
}
Mysql_free_result ($RS);
}
Echo ("</table>");
Mysql_close ($con);
}