致命错误:mysqli_connect() [英] Fatal error: mysqli_connect()
问题描述
我知道那里有很多论坛都在讨论stackoverflow中的这个问题,但是似乎没有一个帮助....试图看看是否有人可以帮我...
I know there are quite a few forums out there talking about this problem in stackoverflow but none seem helped so....trying to see if anyone else can give me a hand...
我安装了mysql服务器5.1,并且在安装过程中未发生任何错误,因此我认为一切都很好,但是当我正在学习并尝试使用php并通过mysql连接时,就会出现此错误消息
I installed mysql server 5.1 and no error happens during the installation so I assume everything is fine but when I'm learning and trying to use php and to connect through mysql and there is this error message saying
Fatal error: Call to undefined function mysqli_connect() in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\books.php on line 3
我的代码在这里
<?php
$db = mysqli_connect("localhost", "root", "3308") or die(mysqli_connect_error());
mysqli_select_db($db, "booksdb") or die(mysqli_error($db));
mysqli_query($db, "CREATE TABLE books(
id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
title VARCHAR(64) NOT NULL)") or die(mysqli_error($db));
mysqli_query($db, "INSERT INTO books(id, title) VALUES(NULL, 'the nose')") or die(mysqli_error());
mysqli_query($db, "INSERT INTO books(id, title) VALUES(NULL, 'the overcoat')") or die(mysqli_error());
mysqli_query($db, "INSERT INTO books(id, title) VALUES(NULL, 'war and peace')") or die(mysqli_error());
$result = mysqli_query($db, "SELECT id, title FROM books") or die(mysqli_error());
while($record = mysqli_fetch_assoc($result)){
echo $record['id'];
echo " ";
echo $record['title'];
echo "<hr/>";
}
?>
在我的php.ini文件中,我都没有注释掉
in my php.ini file I did uncomment both
extension=php_mysql.dll
extension=php_mysqli.dll
,当然也重新启动了Apache.也重新启动了who计算机,但该错误消息不断出现,我不知道如何解决它.我搜索了几个论坛,他们都要求确保扩展名不被注释.还检查了一些论坛站点并尝试了一些.有些我不明白他们在告诉我要尝试什么,但是我尝试过的那些却没有奏效.这里有什么想法吗?
and of course restarted apache. Also restarted the who machine too but that error message keeps on coming up and I have no idea how to fix it. I searched a few forums and they all asked to make sure the extension is uncommented which they are. Also checked few forum sites and tried some. Some I didn't understand what they were telling me to try but the one I tried, none of them worked. Any ideas here?
推荐答案
好的,这可能是您面临的问题的替代解决方案.不过,这还不完全是一个答案.您需要在正确的位置放置php_mysqli.dll
和其他扩展名.您需要检查三个区域:
Okay, this might be an alternate solution to the problem you are facing. Not exactly an answer, though. You need to have php_mysqli.dll
and other extensions in the right place. You need to check in three areas:
- 物理文件
php_mysqli.dll
存在于ext
文件夹中. - 是否正确引用了目录
ext
. - 检查Apache是否有权访问该文件夹.
- 检查您是否编辑了正确的文件.
php.ini
文件可能不止一个.
- The physical file
php_mysqli.dll
existence in theext
folder. - Whether the directory
ext
is correctly referenced. - Check if Apache has access and permissions to the folder.
- Check if you have edited the right file. There might be more than one
php.ini
files.
另一个简单的解决方案是安装如下所示的软件包:
Another simple solution would be installing a package like those below:
- WAMP服务器(我建议小型应用程序使用,也可能适用于实时项目)
- XAMPP
- USB Web服务器
- WAMP Server (I recommend this for small and also may be for live projects)
- XAMPP
- USB Web Server
这篇关于致命错误:mysqli_connect()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!