调用未定义的函数mysqli_connect().尝试过其他类似问题的解决方案,但没有运气 [英] Call to undefined function mysqli_connect(). Tried solution from other similar questions but no luck

查看:73
本文介绍了调用未定义的函数mysqli_connect().尝试过其他类似问题的解决方案,但没有运气的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在标记为重复之前,请理解我已经尝试了其他类似问题中提到的所有解决方案.
我的网站托管在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

  1. 评论:extension=msql.so extension=php_mysqli.dll
  2. 重新启动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.

  1. 由于我在linux中工作,因此需要取消注释msql.so而不是取消注释mysqli.dll.
  2. 第二,我没有评论/etc/php/7.0/apache2/php.ini,而是改为在/etc/php/7.0/cli/php.ini中进行这些更改.
  3. 第三,目录('lib/php/')中没有名为msql.so的文件,而是mysqli.so.因此,将php.ini中的名称从msql.so更改为mysqli.so确实对我有用.
  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.

这篇关于调用未定义的函数mysqli_connect().尝试过其他类似问题的解决方案,但没有运气的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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