作者:_LiNanaP | 来源:互联网 | 2023-02-13 09:10
I am trying to enable mysqli on Mac OS X. I am using MAMP and I have tried XAMPP (I am open to either), but when I open the php.ini file and search for anything containing the word "mysqli" nothing is found, and when I try to run a PHP script containing any mysqli code, nothing happens: no errors are output, the script just fails to execute.
我正在尝试在Mac OS X上启用mysqli。我正在使用MAMP,我尝试过XAMPP(我对任何一个都开放),但是当我打开php.ini文件并搜索包含单词“mysqli”的任何内容时,找不到任何内容,当我尝试运行包含任何mysqli代码的PHP脚本时,没有任何反应:没有输出错误,脚本无法执行。
When I try to connect by
当我尝试连接时
$dbh = new mysqli("localhost","root","root");
and I dump the variable $dbh
it outputs:
我转储变量$ 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) }
This is the code I tried:
这是我试过的代码:
$dbh = new mysqli("localhost","root","root");
$dbh->select_db("php");
$dbh->query("SELECT * FROM test");
$count = $dbh->num_rows;
var_dump($count);
and the output is
而输出是
NULL
2 个解决方案