找不到mysqli.dll [英] not able to find the mysqli.dll
问题描述
试图弄清楚如何在PHP中使用mysql数据库。我运行了
代码:
<?php
//定义数据库连接数据
define( ''DB_HOST'',''localhost'');
define(''DB_USER'',''ajaxuser'');
define('''DB_PASSWORD' ',''实用'');
define(''DB_DATABASE'',''ajax'');
//连接到数据库
$ mysqli = new mysqli(DB_HOST,DB_USER,DB_PASSWORD,DB_DATABASE);
//要执行的SQL查询
$ query =''SELECT user_id, user_name FROM users'';
//执行查询
$ result = $ mysqli-> query($ query);
/ /循环结果
while($ row = $ result-> fetch_array(MYSQLI_ASSOC))
{
//提取用户ID和名字
$ user_id = $ row [''user_id''];
$ user_name = $ row [''user_name''];
//用数据做什么(这里我们输出)
echo''用户名'''。 $ user_id。 ''是''。 $ user_name。 ''< br />'';
}
//关闭输入流
$ result-> close() ;
//关闭数据库连接
$ mysqli-> close();
?>
我收到以下消息,表明它无法找到
mysqli.dll文件:
致命错误:类''mysqli' '找不到
C:\ Apache \htdocs \ ajax\foundations\mysql \ index.php第13行
我在php.ini中有以下内容:
extension = php_mysqli.dll
我在php \ext \中有php_mysqli.dll。我假设这是实现
类的地方。这是正确的吗?
任何想法可能是什么问题?
TIA,
David
trying to figure out how to use a mysql database with PHP. I ran the
following code:
<?php
// defines database connection data
define(''DB_HOST'', ''localhost'');
define(''DB_USER'', ''ajaxuser'');
define(''DB_PASSWORD'', ''practical'');
define(''DB_DATABASE'', ''ajax'');
// connect to the database
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
// the SQL query to execute
$query = ''SELECT user_id, user_name FROM users'';
//execute the query
$result = $mysqli->query($query);
// loop through the results
while ($row = $result->fetch_array(MYSQLI_ASSOC))
{
// extract user id and name
$user_id = $row[''user_id''];
$user_name = $row[''user_name''];
// do somthing with the data (here we output it)
echo ''Name of user #'' . $user_id . '' is '' . $user_name . ''<br/>'';
}
// close the input stream
$result->close();
// close the database connection
$mysqli->close();
?>
I get the following message suggesting that it can''t find the
mysqli.dll file:
"Fatal error: Class ''mysqli'' not found in
C:\Apache\htdocs\ajax\foundations\mysql\index.php on line 13"
I have the following in php.ini:
extension=php_mysqli.dll
I have php_mysqli.dll in php\ext\. I assume that this is where the
class would be implemented. Is that correct?
Any thoughts what the issue might be?
TIA,
David
推荐答案
mysqli = new mysqli(DB_HOST,DB_USER,DB_PASSWORD,DB_DATABASE);
// SQL查询到执行
mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
// the SQL query to execute
query =''SELECT user_id,user_name FROM users'';
//执行查询
query = ''SELECT user_id, user_name FROM users'';
//execute the query
result =
这篇关于找不到mysqli.dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!