Reputation: 95
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>";
}
?>
Upvotes: 1
Views: 256
Reputation: 13549
The function's name is mysql_fetch_array, not mysql_fetch_arrey. So your while loop should like:
while($person = $mysql_fetch_array($result)) {
....
}
Upvotes: 3
Reputation: 86476
Typo here $mysql_fetch_arrey
This should be
while($person = mysql_fetch_array($result))
Upvotes: 0