调用未定义的函数mysqli_connect().尝试过其他类似问题的解决方案,但没有运气 [英] Call to undefined function mysqli_connect(). Tried solution from other similar questions but no luck
问题描述
在标记为重复之前,请理解我已经尝试了其他类似问题中提到的所有解决方案.
我的网站托管在Amazon EC2中.
我已尽一切可能使mysqli_connect
正常工作,但仍未找到解决方案.
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.
在php.ini中尝试了以下操作
Have tried following in php.ini
- 评论:
extension=msql.so
extension=php_mysqli.dll
- 重新启动apache2服务器.
代码如下.
在使用前我已经定义了那些变量.
where i have defined those variables before using.
<?php
$con = mysqli_connect($mysql_host,$mysql_user,$mysql_password);
?>
我得到的错误是
致命错误:未捕获错误:调用/var/www/html/connect.php:2中未定义的函数mysqli_connect()
Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /var/www/html/connect.php:2
请支持我.
推荐答案
我终于得到了解决方案. 我做错了三件事.
I finally got the solution. There were three things I was doing wrong.
- 由于我在linux中工作,因此需要取消注释
msql.so
而不是取消注释mysqli.dll
. - 第二,我没有评论
/etc/php/7.0/apache2/php.ini
,而是改为在/etc/php/7.0/cli/php.ini
中进行这些更改. - 第三,目录('lib/php/')中没有名为
msql.so
的文件,而是mysqli.so
.因此,将php.ini
中的名称从msql.so
更改为mysqli.so
确实对我有用.
- Since i am working in linux, uncommenting
msql.so
was required rather then uncommentingmysqli.dll
. - 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
. - Third, the file named
msql.so
was not there in the directory ('lib/php/'), instead it wasmysqli.so
. Therefore changing the name frommsql.so
tomysqli.so
inphp.ini
did the trick for me.
希望这有一天会有所帮助.
Hope this will help somebody someday.
这篇关于调用未定义的函数mysqli_connect().尝试过其他类似问题的解决方案,但没有运气的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!