View Single Post
Old 06-14-2007, 09:26 AM   #3 (permalink)
Salchester
Salchester
 
Salchester's Avatar
 
Join Date: Jul 2005
Location: In a house
Posts: 230
Salchester is an unknown quantity at this point
Insert Table Data into Array

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,
__________________
Many Thanks, in advance!

Salchester.
The Future Is Here - Are You Ready?
Salchester is offline   Reply With Quote