2011-06-27 297 views
1

我只是一個初學者,只是試圖從數據庫讀取數據。有2個文件,一個是包含數據庫連接代碼的文件,另一個是我給出的下面代碼的第二部分。在數據庫中,3有列:1.id,2.name和3描述當我嘗試在Firefox中打開位於文件夾它顯示數據庫連接問題

"Fatal error: Call to undefined function mysql_fetch_arrey() in C:\xampp\htdocs\www\database connection\index.php on line 8"

8 NUM線

"while($person = mysql_fetch_arrey($result))"

我正在檢查「 mysql_fetch_arrey($ result)「與」$ mysql_fetch_arrey($ result)「

,但它顯示

"Fatal error: Function name must be a string in C:\xampp\htdocs\www\database connection\index.php on line 8"

我使用的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>"; 
    } 

?> 

回答

3

函數的名字是mysql_fetch_array,不mysql_fetch_arrey。所以,你的while循環想:

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

喔!! ...我是多麼愚蠢...:P ...是的, 你是對的。這是一個拼寫錯誤。我必須提高自己的觀察能力,並且非常感謝你的建議。 – webrider

0

錯字這裏$mysql_fetch_arrey

這應該是

while($person = mysql_fetch_array($result)) 
+0

yupzz !! ....疑難雜症....日Thnx沙克提:) – webrider