开发者

PDO--why this code can't connect the database?

         <?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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜