Linux PHP 致命错误:调用未定义的函数 mysqli_connect()

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19719719/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 19:55:11  来源:igfitidea点击:

Linux PHP Fatal error: Call to undefined function mysqli_connect()

phpmysqlapachemysqli

提问by valbu17

I have a problem regarding connecting the database it is giving this error

我在连接数据库时遇到问题,出现此错误

Fatal error: Call to undefined function mysqli_connect()

Which, I have spend the past 4 hours trying to figured out and I already did these steps:

其中,我花了过去 4 个小时试图弄清楚,我已经完成了以下步骤:

  1. Change extension=mysql.so and extension=mysqli.so
  2. extension_dir=/PATH for php.ini
  3. Checked which modules are loaded or install with php - m
  1. 更改 extension=mysql.so 和 extension=mysqli.so
  2. php.ini 的 extension_dir=/PATH
  3. 使用 php -m 检查加载或安装了哪些模块

I JUST PUT MY INFOPHP() IN PASTEBIN SORRY, MY WEBSITE IS RUNNING UNDER USERNAME AND PASSWORD PROTECTING BECAUSE IS A PRIVATE UNIVERSITY SERVER..

我只是把我的 INFOPHP() 放在 Pastebin 中 抱歉,我的网站正在以用户名和密码保护运行,因为它是一个私人大学服务器..

http://pastebin.com/dKKdwWTb

http://pastebin.com/dKKdwWTb

I am not too sure what else I can do about, just in case I have added the link for paste bin for my php.ini file

我不太确定我还能做什么,以防万一我为我的 php.ini 文件添加了粘贴箱的链接

http://pastebin.com/QNK6mGqV

http://pastebin.com/QNK6mGqV

Well, I hope someone could see what I have been able to see and could help me out.

好吧,我希望有人能看到我所看到的并能帮助我。

回答by Itay Moav -Malimovka

Check output of phpinfo() in web page. php -m is for cli, your mod_apache probably be using a different php.ini than the cli one.

检查网页中 phpinfo() 的输出。php -m 用于 cli,您的 mod_apache 可能使用了与 cli 不同的 php.ini。

edit

编辑

After seeing your web phpinfo()we can see my assumption is correct. You really are using a different php.ini for your apache, and in it the mysqli extension is not enabled.
in the phpinfo() output you have the details on where to find the php.ini file, and where is the extension directory.

看到你的网页后,phpinfo()我们可以看到我的假设是正确的。您确实为您的 apache 使用了不同的 php.ini,并且其中未启用 mysqli 扩展。
在 phpinfo() 输出中,您有关于在哪里可以找到 php.ini 文件以及扩展目录在哪里的详细信息。

Cheers.

干杯。

回答by Parag

I was receiving the same error, and I had just installed MySQL Server 5.5, but I had forgotten to restartthe Apache server. On Ubuntu systems you can issue the following command to restart:

我收到了同样的错误,我刚刚安装了 MySQL Server 5.5,但我忘记重新启动Apache 服务器。在 Ubuntu 系统上,您可以发出以下命令来重新启动:

sudo service apache2 restart

After I restarted, I was no longer receiving that particular error message!

重新启动后,我不再收到该特定错误消息!