Hello all,
I'm new to mysql, but I've managed to cobble together a script that does everything exactly as I want it to. The problem is I'm getting Warnings when I run through certain loops in the script, but I don't see any errors.
Here is the warning:
Code:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/.fitch/awkemp/kempa.com/aadl/index.phtml on line 33
...and here is the general area of line 33 in the code:
Code:
if ($endses) {
if (!$stationnumber || strlen($stationnumber) > 1 || $stationnumber > 3 || ereg("^[[:alpha:]]$", $stationnumber) || ereg("^[-!#@$%&\'\;:<>?\|*~+\\./0-]$", $stationnumber)){
echo "<center>Invalid station number entered.<P><a href=\"index.phtml\">Back</a></center>";
}
else{
$result = mysql_query("SELECT * FROM stations",$db);
while($myrow = mysql_fetch_array($result)){
if ($myrow["id"] == $stationnumber && $myrow["status"] != 'Out of order') {
echo "<center>Session Ended.<P>";
echo "<a href=\"index.phtml\">Back</a><P></center>\n";
$id = $myrow["id"];
$sql = "UPDATE stations SET cardnumber=NULL,last=NULL,first=NULL,status='Available' WHERE id=$id";
$result = mysql_query($sql,$db);
}
else{
if ($myrow["id"] == $stationnumber) {
echo "<center>Station is out of order. No session exists.<P><a href=\"index.phtml\">Back</a></center>";
}
}
}
}
}
Any Suggestions?
I can post the rest of the code if neccesary.
Thanks!
Adam