【发布时间】:2011-10-26 15:29:20
【问题描述】:
我正在尝试在 Mac OS X 上启用 mysqli。我正在使用 MAMP,我已经尝试过 XAMPP(我对任何一个都开放),但是当我打开 php.ini 文件并搜索包含单词“mysqli”的任何内容时什么也没找到,当我尝试运行包含任何 mysqli 代码的 PHP 脚本时,什么也没有发生:没有输出错误,脚本只是无法执行。
当我尝试连接时
$dbh = new mysqli("localhost","root","root");
然后我转储它输出的变量$dbh:
object(mysqli)#1 (17) { ["affected_rows"]=> int(0) ["client_info"]=> string(5) "5.5.9" ["client_version"]=> int(50509) ["connect_errno"]=> int(0) ["connect_error"]=> NULL ["errno"]=> int(0) ["error"]=> string(0) "" ["field_count"]=> int(0) ["host_info"]=> string(25) "Localhost via UNIX socket" ["info"]=> NULL ["insert_id"]=> int(0) ["server_info"]=> string(5) "5.5.9" ["server_version"]=> int(50509) ["sqlstate"]=> string(5) "00000" ["protocol_version"]=> int(10) ["thread_id"]=> int(12) ["warning_count"]=> int(0) }
这是我试过的代码:
$dbh = new mysqli("localhost","root","root");
$dbh->select_db("php");
$dbh->query("SELECT * FROM test");
$count = $dbh->num_rows;
var_dump($count);
输出是
NULL
【问题讨论】:
-
你用的是什么版本的php、mam、xampp? (也检查 phpinfo)
-
5.3.6 ,我的印象是它是用那个版本的 php 编译的,当我在显示 phpinfo() 时搜索“mysqli”时,它表明 mysqli 已启用。
-
那么会不会有什么东西导致这些脚本无法运行,它们似乎没有产生任何错误消息,但之后没有运行任何 php 脚本。
-
可以发一个失败的小脚本吗?
-
我什至无法连接例如:$dbh = new mysqli("localhost","root","root","php");之后不会运行任何 php 脚本,如果我尝试只查询数据库,则什么也没有发生,什么也没有显示。请检查编辑,感谢您的帮助和坚持
标签: php mysql mysqli xampp mamp