致命错误:在将PHP 5.4.22和MySQL 5.5与Apache 2.4.7连接时,在...中调用未定义函数mysqli_connect() [英] Fatal error: Call to undefined function mysqli_connect() in... while connecting PHP 5.4.22 and MySQL 5.5 with Apache 2.4.7
问题描述
我正在尝试将PHP 5.4.22和MySQL 5.5与Apache 2.4.7作为Web服务器连接.所有这三个都可以正常工作.但是,当我尝试将PHP与MySQL连接时,出现错误消息:
I am trying to connect PHP 5.4.22 and MySQL 5.5 with Apache 2.4.7 as the web server. All three of these individually are working fine. However, when I try to connect PHP with MySQL I get the error:
致命错误:在...中调用未定义的函数mysqli_connect()"
"Fatal error: Call to undefined function mysqli_connect() in..."
db_connect.php代码
$con = mysqli_connect("localhost","root","root","mylab_dev");
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$conn->close();
httpd.conf配置:
ServerRoot "c:/Apache24"
#Listen 12.34.56.78:80
Listen 80
LoadModule php5_module "C:/php/php5apache2_4.dll" (Verified the existence of the physical file)
AddHandler application/x-httpd-php .php
DirectoryIndex index.php index.html
PHPIniDir c:/php
将php.ini-development文件修改为php.ini
Modified php.ini-development file to php.ini
; extension_dir = "./"
; On windows:
extension_dir = "ext"
extension=php_mysql.dll --> Uncommented
extension=php_mysqli.dll --> Uncommented
相应地设置日期时区
我注意到一件事,但不确定是否是原因,在phpinfo()
页中,我看到了MySQL信息,但没有看到任何显示mysqli()
的信息.我应该吗?
One thing I noticed but not sure if this is the reason, in the phpinfo()
page I see the MySQL information, but I don't see anything which says mysqli()
. Should I?
推荐答案
首先,通过从phpinfo()
进行检查,确保您正在编辑正确的php.ini
.
First of all, make sure you are editing the correct php.ini
by checking from the phpinfo()
.
我主要为Windows用户编写了这些说明:
I wrote these instructions mainly for Windows users:
编辑您的php.ini
.
检查变量extension-dir
是否设置正确.如果没有,请根据您的操作系统指定正确的路径.
Check whether variable extension-dir
is set properly. If not, specify the correct path as per your OS.
extension_dir = "C:\Program Files\php\ext"
通过删除;
(分号)取消注释这些行:
Un-comment these lines by removing the ;
(semi-colon):
extension=php_mysql.dll
extension=php_mysqli.dll
这篇关于致命错误:在将PHP 5.4.22和MySQL 5.5与Apache 2.4.7连接时,在...中调用未定义函数mysqli_connect()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!