Fatal error: Call to undefined function mysqli_connect()(致命错误:调用未定义函数 mysqli_connect())
问题描述
2 天来,我正在尝试解决这个问题,但不幸的是没有结果.让我告诉你我关于这个问题的故事.我在网站上构建了一个应用程序,该应用程序处理评论.但是,我试图把它放在另一个站点上,我从旧站点复制了 php 文件和 sql 文件,并将它们移动到新站点(它们位于不同的 FTP 服务器上).当我尝试从应用程序访问页面时,我收到此 FATAL ERROR:
For 2 days now I'm trying to solve this, but unfortunately no result. Let me tell you my story about the problem. I've bulid an application on a site, and the application deals with the reviews. But, I'm trying to put it on another site, and I copyed the php files, the sql file from the old site, and moved them to the new site (they are on different FTP servers). When I'm trying to go to the pages from the application, I receive this FATAL ERROR:
致命错误:调用未定义函数 mysqli_connect()
Fatal error: Call to undefined function mysqli_connect()
我编写的连接数据库的代码是这样的(带有隐藏凭据):
The code that I wrote to connect to the database is this (with hidden credentials):
$con = mysqli_connect("","*the_name*","*the_pass*","*the_database*");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
为什么我会收到错误消息?它可以在旧服务器上运行,我认为代码不是问题,因为它可以在 localhost 上运行,而在新服务器上则不行.谁能帮帮我?
Why do I get the error? It works on the old server, and the code I think it's not the problem, because it works on localhost, and on the new server it doesn't. Can anyone help me?
推荐答案
简单做
sudo apt install php-mysqli
完美运行,并且与版本无关
It works perfectly and it is version independent
这篇关于致命错误:调用未定义函数 mysqli_connect()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:致命错误:调用未定义函数 mysqli_connect()


- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- Laravel 仓库 2022-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01