数据库连接问题

发布于 2024-11-17 02:30:57 字数 1897 浏览 0 评论 0原文

我只是一个初学者,只是尝试从数据库读取数据。有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

内心激荡 2024-11-24 02:30:58

该函数的名称是 mysql_fetch_array,而不是 mysql_fetch_arrey。所以你的 while 循环应该像:

while($person = $mysql_fetch_array($result)) {
    ....
}

The function's name is mysql_fetch_array, not mysql_fetch_arrey. So your while loop should like:

while($person = $mysql_fetch_array($result)) {
    ....
}
野却迷人 2024-11-24 02:30:58

这里错字 $mysql_fetch_arrey

这应该是

while($person = mysql_fetch_array($result))

Typo here $mysql_fetch_arrey

This should be

while($person = mysql_fetch_array($result))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文