Home > Backend Development > PHP Tutorial > Summary of 2 ways to connect MySQL with PHP and prevent garbled characters_PHP tutorial

Summary of 2 ways to connect MySQL with PHP and prevent garbled characters_PHP tutorial

WBOY
Release: 2016-07-13 10:36:15
Original
994 people have browsed it

MySQL configuration for PHP

Error message: Class 'mysqli' not found in

Answer:
1. In conf/php.ini, use "/php_mysql" in vim to search for extension=php_mysql.dll, and remove the previous ";",

Also add extension=php_mysqli.dll;

Note that the dll at the back has an extra i
2. "/extension_dir" check whether the path is correct;

3. Find the ext/ directory and copy the two files php_mysql.dll and php_mysqli.dll to %systemroot%/system32.

4. Restart the service

Connect to database

Copy code The code is as follows:

//In conf/php.ini, use "/php_mysql" in vim to search extension=php_mysql.dll, remove the ";" in front, and add extension=php_mysqli.dll;
$mysqli = new mysqli("127.0.0.1","Username", Password","Library Name");
$query="select * from table order by theindex desc";
$mysqli- >query("SET NAMES gb2312");//Please note that if you don’t add it here, it will cause garbled characters
$result = $mysqli->query($query);

//printf() function outputs a formatted string
while(list($name, $theindex) = $result->fetch_row())
echo("
".$name.$theindex);

$con = mysql_connect("localhost", "username", "password");
if ($con) {
mysql_query("set names 'gb2312'");
mysql_select_db( "Library name", $con);//Please note that no garbled characters will be added here. if ($rs) // 🎜>                                                                                                                               ​ " $row[theindex]" .
"$row[name]" .
"";
}
mysql_free_result($rs);
}
echo ("");
mysql_close($con);
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/740211.htmlTechArticlePHP’s MySQL configuration error message: Class 'mysqli' not found in Answer: 1. In conf/php.ini , use "/php_mysql" in vim to search for extension=php_mysql.dll, remove the ";" in front, and add...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template