Call to undefined function mysqli_connect(). Tried

2019-09-19 16:01发布

问题:

Before marking duplicate please understand that I have tried all the solutions mentioned in other similar question.
I have hosted my website in amazon ec2. I have done everything possible to make mysqli_connect work, still didn't find solution for it.

Have tried following in php.ini

  1. comment out : extension=msql.so extension=php_mysqli.dll
  2. restarted apache2 server.

the code is as follows.

where i have defined those variables before using.

<?php
$con = mysqli_connect($mysql_host,$mysql_user,$mysql_password);
?>

The error I am getting is

Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /var/www/html/connect.php:2

Please be supportive and help me..

回答1:

I finally got the solution. There were three things I was doing wrong.

  1. Since i am working in linux, uncommenting msql.so was required rather then uncommenting mysqli.dll.
  2. Second, I was uncommenting in /etc/php/7.0/apache2/php.ini, but instead i was to make those changes in cli i.e /etc/php/7.0/cli/php.ini.
  3. Third, the file named msql.so was not there in the directory ('lib/php/'), instead it was mysqli.so. Therefore changing the name from msql.so to mysqli.so in php.ini did the trick for me.

Hope this will help somebody someday.