为什么mysqli_connect()是“未定义的函数"?在我的PHP服务器上? [英] Why is mysqli_connect() an "undefined function" on my PHP server?
问题描述
我正在Linux服务器上使用PHP版本5.3.3.当我尝试使用mysql_connect()或mysqli_connect()到达数据库时,出现错误消息:
I'm using PHP Version 5.3.3 on a Linux server. When I try to use mysql_connect() or mysqli_connect() to reach the database, I get an error saying:
致命错误:调用未定义的函数mysql_connect()
Fatal error: Call to undefined function mysql_connect()
或
致命错误:调用未定义的函数mysqli_connect()
Fatal error: Call to undefined function mysqli_connect()
您可以在此处查看我的测试页面: http://gorp.osg.ufl. edu/BOT3151/testing.php
You can see my testing page here: http://gorp.osg.ufl.edu/BOT3151/testing.php
您可以在此处查看phpinfo页面: http://gorp.osg.ufl.edu/phptest.php
You can see the phpinfo page here: http://gorp.osg.ufl.edu/phptest.php
相关的配置命令在这里:
The relevant configure commands are here:
'--with-mysql=shared,/usr'
'--with-mysqli=shared,/usr/lib64/mysql/mysql_config'
'--with-pdo-mysql=shared,/usr/lib64/mysql/mysql_config'
'--with-mysql=shared,/usr'
'--with-mysqli=shared,/usr/lib64/mysql/mysql_config'
'--with-pdo-mysql=shared,/usr/lib64/mysql/mysql_config'
它还表示正在解析以下.ini文件:
It also says that these .ini files are being parsed:
/etc/php.d/mysql.ini
/etc/php.d/mysqli.ini
/etc/php.d/mysql.ini
/etc/php.d/mysqli.ini
php.ini文件还包括以下几行:
The php.ini file also includes these lines:
extension=mysql.so
extension=mysqli.so
extension=mysql.so
extension=mysqli.so
那么这里出了什么问题?服务器上未正确安装mySQL吗?我该如何解决?
So what's going wrong here? Is mySQL not properly installed on the server? How can I fix this?
附录:我应该已经解释说,这是在我不管理的共享服务器上.我只能通过SFTP访问服务器上的文件夹.但是我确实有一个php.ini文件,并且我有一个extensions文件夹.那么,这是我可以自己解决的还是我需要服务器管理员的帮助吗?
ADDENDUM: I should have explained that this is on a shared server that I don't administer. I just have access to my folder on the server through SFTP. But I do have a php.ini file and I have an extensions folder. So is this something I can fix myself or do I need help from a server administrator?
推荐答案
"mysqli"扩展名未加载.您无法在phpinfo()文件中看到该部分.
The "mysqli" extension is not loaded. You can NOT see the section in your phpinfo() file.
http://gorp.osg.ufl.edu/phptest.php
您应该在该页面上看到以下内容: https://drive.google.com/open?id=0B7VdYIkRLxQWaDRLYVNLeU84am8
You should see something like this on that page: https://drive.google.com/open?id=0B7VdYIkRLxQWaDRLYVNLeU84am8
仅因为您已取消注释行extension=mysqli.so
并不意味着它将加载.文件mysqli.so
可能不在PHP所寻找的文件夹中,或者根本不存在.
Just because you have uncommented the line extension=mysqli.so
does not mean it will load. The file mysqli.so
is possibly not in a folder where PHP is looking for it or does not exist at all.
在您的php.ini
文件中检查"extension_dir".然后去看看文件mysqli.so
是否确实存在.
Check "extension_dir" in your php.ini
file. Then go and see if the file mysqli.so
is actually there.
您重新启动了Web服务器吗?
Have you restarted your web server?
这篇关于为什么mysqli_connect()是“未定义的函数"?在我的PHP服务器上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!