数据库连接问题
我只是一个初学者,只是尝试从数据库读取数据。有 2 个文件,一个是包含数据库连接代码的包含文件,另一个是我给出的以下代码的第二部分。在数据库中,有 3 列:1.id ,2.name 和 3.description 当我尝试在 Firefox 中打开找到的文件夹时,它会显示
“致命错误:调用未定义 函数 mysql_fetch_arrey() 中 C:\xampp\htdocs\www\database 第 8 行的连接\index.php"
第 8 行是
“同时($人= mysql_fetch_arrey($结果))"
我用“$mysql_fetch_arrey($result)”检查了“mysql_fetch_arrey($result)”,
但它显示
“致命错误:函数名称必须是 C:\xampp\htdocs\www\database 中的字符串 第 8 行的连接\index.php"
我使用 adobe dreamwaver5 和 xampp 服务器
第一页:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>connection</title>
</head>
<body>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$db = 'db_connection';
$conn = mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($db);
?>
</body>
</html>
</body>
</html>
第二页:
<?php
include 'connection.php';
$query = "SELECT * FROM people";
$result = mysql_query($query);
while($person = $mysql_fetch_arrey($result))
{
echo "<h3>".$person['name']."</h3>";
echo "<p>".$person['description']."</p>";
}
?>
i am just a beginner and simply trying to read data from a db.there are 2 files, one is include file which contains db connection code and another the 2nd part of my given below code.In db, 3 columns there: 1.id, 2.name and 3. description when i try to open the located folder in firefox it shows
"Fatal error: Call to undefined
function mysql_fetch_arrey() in
C:\xampp\htdocs\www\database
connection\index.php on line 8"
the 8 num line is
"while($person =
mysql_fetch_arrey($result))"
i am checked the "mysql_fetch_arrey($result)" with "$mysql_fetch_arrey($result)"
but it shows
"Fatal error: Function name must be a
string in C:\xampp\htdocs\www\database
connection\index.php on line 8"
i use adobe dreamwaver5 and xampp server
1st page :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>connection</title>
</head>
<body>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$db = 'db_connection';
$conn = mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($db);
?>
</body>
</html>
</body>
</html>
2nd page :
<?php
include 'connection.php';
$query = "SELECT * FROM people";
$result = mysql_query($query);
while($person = $mysql_fetch_arrey($result))
{
echo "<h3>".$person['name']."</h3>";
echo "<p>".$person['description']."</p>";
}
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该函数的名称是 mysql_fetch_array,而不是 mysql_fetch_arrey。所以你的 while 循环应该像:
The function's name is mysql_fetch_array, not mysql_fetch_arrey. So your while loop should like:
这里错字
$mysql_fetch_arrey
这应该是
Typo here
$mysql_fetch_arrey
This should be