Hi everyone
I get the folowing error when i run this page:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
It is generated at the while statement. What is confusing is that this error has only resulted since I added the if ($rs="") statement. If i comment it out as i have done below the page executes fine. I can not see why the If statement would be causing this error, any help would be great.
<?php
$query = "select * from announcetemp";
$rs = mysql_query($query) or die ('could not select all') ;
$list = "<table width=\"760\" colspan=\"4\" border=\"0\" cellpadding=\"2\" bgcolor=\"#FFFFFF\">";
//if ($rs ="")
//{
//$list .= "<br><br><tr> There are no announcements currently awaiting approval </tr><br><br>";
//}
while ( $row = mysql_fetch_array($rs))
{
//NEED TO ADD CSS CODE TO SPACE ELEMENTS OUT CORRECTLY
$list .= "<tr>-----------------------------------------------------------------------------------------------------------------------";
$list .= "<br><tr><b>Title </b>".$row["subject"]." <b>                 Posted On </b>".$row["postdate"]."</tr>";
$list .= "<br><tr>".$row["body"]."</tr>";
if ($row["filepath"] !="") //there is an associated file so show link
{
$list .= "<tr><a href=".$row["filepath"].">Click here </a> to view associated file</tr>";
}
$list .= "<br><br><tr>
<form action=\"approveannouncements.php\" method=\"post\" class=\"button\">
<input type=\"submit\" name=\"delete\" value=\"Delete\">
<input type=\"hidden\" name=\"annoid\" value=".$row["annoid"]."> </form>
<form action=\"approveannouncements.php\" method=\"post\" class=\"button\">
<input type=\"submit\" name=\"approve\" value=\"Approve\">
<input type=\"hidden\" name=\"annoid\" value=".$row["annoid"]."> </form>
<form action=\"editannounce.php\" method=\"post\" class=\"button\">
<input type=\"submit\" name=\"edit\" value=\"Edit\">
<input type=\"hidden\" name=\"annoid\" value=".$row["annoid"]."> </form>
</tr>";
$list .= "</tr>";
}
$list .= "</table>";
echo ($list);
?>