Page 1 of 1

[SOLVED][Warning: mysql_fetch_array(): supplied argument

Posted: Mon Feb 09, 2004 7:11 am
by William
I don't under stand why it is giving me this error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/william/public_html/gb_posts.php on line 9
Here is the code on line 9:

Code: Select all

while ($myrow = mysql_fetch_array($result)){
And here is the whole page:

Code: Select all

<?php
include("link-to-the-file-containing-users/host/table-.ect");

if(!isset($start)) $start = 0;
$link = mysql_connect( "$host", $user, $pass );
mysql_select_db( $database, $link ) or die ("Couldn't select database.");
$query =  "SELECT * FROM $table ORDER BY id DESC LIMIT " . $start . ", 10";
$result = mysql_query($query, $link);
while ($myrow = mysql_fetch_array($result)){

$name = $myrow['name'];
$email = $myrow['email'];
$url = $myrow['url'];
$city = $myrow['city'];
$message = $myrow['message'];

	print "<hr size='1' width='470' color='#FFFFFF' />";
	print "<table cellpadding='0' cellspacing='0' border='0' width='470' align='center'>";
	print "<tr>";
	print "<td><font size='1' face='verdana'><b>Name:</b> <a href='mailto:$email'>$name</a></font></td>";
	print "</tr>";
	print "<tr>";
	print "<td><font size='1' face='verdana'><b>Homepage:</b> <a href='$url'>$url</a></font></td>";
	print "</tr>";
	print "<tr>";
	print "<td><font size='1' face='verdana'><b>City:</b> $city</font></td>";
	print "</tr>";
	print "<tr>";
	print "<td><font size='1' face='verdana'><b>Sent:</b> 19.40 - 8/2</font></td>";
	print "</tr>";
	print "<td><font size='1' face='verdana'><br />";
	print "$message";
	print "</font></td>";
	print "</tr>";
	print "</table>";
}

$num_names_per_page = "10";
$next_name = "Next";
$last_name = "Last";

$query = "SELECT count(*) as count FROM $table";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$numrows = $row['count'];
if (($start > 0) && ($numrows > ($start + 10))) {
   echo "<br><a href="" . $PHP_SELF . "?start=" . ($start - $num_names_per_page) . "">[ $last_name</a>";
   echo "  ||  <a href="" . $PHP_SELF . "?start=" . ($start + $num_names_per_page) . "">$next_name ]</a>";
}elseif ($start > 0){
   echo "<br><a href="" . $PHP_SELF . "?start=" . ($start - $num_names_per_page) . "">[ $last_name ]</a>";
}elseif ($numrows > ($start + 10)){
   echo "<a href="" . $PHP_SELF . "?start=" . ($start + $num_names_per_page) . "">[ $next_name ]</a>";
}
?>
If you can help thanks.

Posted: Mon Feb 09, 2004 7:41 am
by William
Ahhh! Figured it out I forget to make a field names id. sorry.