Home  >  Article  >  Backend Development  >  Two ways to connect MySQL with PHP and prevent garbled characters_PHP tutorial

Two ways to connect MySQL with PHP and prevent garbled characters_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:39:22738browse

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
//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");//Note that if you don’t add it here, the code will be garbled
$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);//Note that if you don’t add it here, it will cause garbled characters
                                        $rs = mysql_query("select * from table order by theindex desc;", $con);
If ($rs) {
echo ("

");
                                                                                                                                                                                                                                                                                                                                                                                                            echo "" .
"" .
"" .
"";
                                                                 mysql_free_result($rs);
                                                                 echo ("
$row[theindex]$row[name]
");
mysql_close($con);
}



http://www.bkjia.com/PHPjc/730939.html

www.bkjia.com

http: //www.bkjia.com/PHPjc/730939.htmlTechArticlePHP’s MySQL configuration error message: Class 'mysqli' not found in Answer: 1. In conf/php.ini In vim, use /php_mysql to search for extension=php_mysql.dll, remove the previous;, and add below...
Statement:
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