Fatal error: Call to undefined function mysqli_con

2019-01-03 10:43发布

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:

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();
}

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?

标签: php mysql ftp
12条回答
劫难
2楼-- · 2019-01-03 11:01

Happens when php extensions are not being used by default. In your php.ini file, change
;extension=php_mysql.dll
to
extension=php_mysql.dll.

**If this error logs, then add path to this dll file, eg
extension=C:\Php\php-???-nts-Win32-VC11-x86\ext\php_mysql.dll

Do same for php_mysqli.dll and php_pdo_mysql.dll. Save and run your code again.

查看更多
对你真心纯属浪费
3楼-- · 2019-01-03 11:06

The mysqli PHP extension is not installed on your new server.

Contact to your server administrator.

查看更多
兄弟一词,经得起流年.
4楼-- · 2019-01-03 11:08

if you use ubuntu 16.04 (maybe and above),you have this module already but not enabled by default. Just do this:

sudo phpenmod mysqli
查看更多
放荡不羁爱自由
5楼-- · 2019-01-03 11:10

There is no error in the, but the mysqli PHP extension is not installed on your machine. Please contact your service provider to fix this issue.

查看更多
对你真心纯属浪费
6楼-- · 2019-01-03 11:14

On Ubuntu I had to install php5 mysql extension.

apt-get install php5-mysql

查看更多
▲ chillily
7楼-- · 2019-01-03 11:14

Late to the conversation...

If you have the module installed and set your PHP.INI file properly, check your apache error log for something like the following:

PHP Warning: PHP Startup: Unable to load dynamic library 'C:\php\ext\php_mysqli.dll' - The specified module could not be found.

In this case, your extension directory is not what you think it is. You may neeed to set it explicitly, like so:

extension_dir="C:\xampp\php\ext"
查看更多
登录 后发表回答