SDE,
Upon execution of the code you supplied, the following error messages appear. Why is this?
- Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in
C:\Documents and Settings\Dale Piper\Desktop\xampplite\htdocs\Array.php on line 13
- Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in
C:\Documents and Settings\Dale Piper\Desktop\xampplite\htdocs\Array.php on line 19
Code:
<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
// your query
$result = mysql_query("select * from Birds");
// use mysql_fetch_array to get a numerically indexed array
while ($array = mysql_fetch_array($result)) {
echo $array[0] . '<br />';
}
// alternatively, you could use mysql_fetch_assoc if you wanted
// the array to be keyed by the field name
while ($array = mysql_fetch_assoc($result)) {
echo $array['Name'] . '<br />';
}
?>
Many Thanks,