<?php
$host = 'localhost';
$db='mysql';
$user = 'r开发者_StackOverflowoot';
$pass = 123;
$conn = new PDO("mysql:host=$host;dbname=$db",$user,$pass);
if($conn){
echo 'ok';
}else {
echo 'error';
}
?>
why this code can't connect the database? my php.ini file setting is right,
extension=php_pdo.dll
extension=php_pdo_mysql.dll
the database user is root, the password is 123. thank you
If you are at the beginning of a project and are unable to make PDO work, you might be able to have more luck with mySQLi.
http://php.net/manual/en/book.mysqli.php
精彩评论