Why am I getting this error???
Warning: Supplied argument is not a valid MySQL result resource in /usr/local/etc/httpd/htdocs/idema/new_site_html/again/search_options.php on line 35
//Perform query depending on user's selection
if(($region=="all")and($countries=="all"))
{
$result = mysql_query("SELECT * FROM trips WHERE cost>='$price1' AND cost<='$price2'",$db);
$flag1="flag1! region=all and countries=all query executed!";
}
else if(($region)and($countries=="all"))
{
$result = mysql_query("SELECT * FROM trips WHERE region='$region' AND cost>='$price1' AND cost<='$price2'",$db);
$flag2="flag2! region was set and countries=all query executed!";
}
else if(($region)and($countries)and($price1)and($price2))
{
$result = mysql_query("SELECT * FROM trips WHERE region='$region' AND country='$countries' AND cost>='$price1' AND cost<='$price2'",$db);
$flag3="flag3! region set, countries set, price1 and price2 set!";
}
//Output Table
//This is where I am getting errors
if ($myrow = mysql_fetch_row($result))
{
echo "<table border=2>\n";
echo "<tr><td>Trip Name</td><td>Region</td><td>Country</td><td>Description</td><td>Cost</td><td>Duration</td><td>Lodging</td><td>Grade</td>";
do{
printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n", $myrow["trp_name"], $myrow["region"], $myrow["country"], $myrow["description"], $myrow["cost"], $myrow["duration"], $myrow["lodging"], $myrow[grade]);
}
while ($myrow=mysql_fetch_array($result));
echo "</table>\n";
}
else
{
echo "Sorry, no records were found.";
}
echo "$flag1";
echo "$flag2";
echo "$flag3";
?>
</body>