nuthead
11-23-2003, 10:23 AM
I have coded something that will either show or delete a line depending on the date, the only problem is that if a row gets deleted during the "while" loop it will cause an error as it wasnt expecting to lose a value from the mysql_fetch_row() array.
Here is my code...
while(list($band,$country,$months,$lastdate,$support,$date) = mysql_fetch_row($result)) {
$today = time();
$d = split("-",$lastdate);
$date_seconds = mktime(0,0,0,$d[2],$d[1],$d[0]);
if ($today > $date_seconds) {
$result = mysql_query("DELETE FROM gig_listings WHERE band = '$band' AND country = '$country' LIMIT 1");
}
else {
echo "<br><a href=\"show.php?band=$band&country=$country\">$band</a> ($months)";
}
}
I get the error: Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in *path*\list.php on line 16
(line 16 is the one with the while() on it)
It works fine, just as long as there is no data to delete! Any help would be much appreciated!
Here is my code...
while(list($band,$country,$months,$lastdate,$support,$date) = mysql_fetch_row($result)) {
$today = time();
$d = split("-",$lastdate);
$date_seconds = mktime(0,0,0,$d[2],$d[1],$d[0]);
if ($today > $date_seconds) {
$result = mysql_query("DELETE FROM gig_listings WHERE band = '$band' AND country = '$country' LIMIT 1");
}
else {
echo "<br><a href=\"show.php?band=$band&country=$country\">$band</a> ($months)";
}
}
I get the error: Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in *path*\list.php on line 16
(line 16 is the one with the while() on it)
It works fine, just as long as there is no data to delete! Any help would be much appreciated!