致命错误:调用未定义函数 mysqli_connect() [英] Fatal error: Call to undefined function mysqli_connect()

查看:51
本文介绍了致命错误:调用未定义函数 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()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆