数据库连接问题

时间:2011-06-27 09:50:56

标签: php

我只是一个初学者,只是尝试从db.there读取数据有两个文件,一个是包含db连接代码的include文件,另一个是我给定的下面代码的第二部分。在db中,有3列: 1.id,2.name和3.当我尝试在firefox中打开找到的文件夹时显示

  

“致命错误:调用未定义   函数mysql_fetch_arrey()in   C:\ XAMPP \ htdocs中\ WWW \数据库   第8行的连接\ index.php“

8号线是

  

“while($ person =   mysql_fetch_arrey($结果))“

我用“$ mysql_fetch_arrey($ result)”检查了“mysql_fetch_arrey($ result)”

但它显示

  

“致命错误:函数名称必须是a   C:\ xampp \ htdocs \ www \ database中的字符串   第8行的连接\ index.php“

我使用adobe dreamwaver5和xampp服务器

第1页:

   <!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>

第2页:

<?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>";
    }

?>

2 个答案:

答案 0 :(得分:3)

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

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

答案 1 :(得分:0)

错字$mysql_fetch_arrey

这应该是

while($person = mysql_fetch_array($result))