Weird, weird, weird!
| From: | Mike At Spy | Date: | Tue, 08 Oct 2002 20:13:02 +0000 |
| Subject: | Weird, weird, weird! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-119327@lists.php.net to get a copy of this message | ||
Anyone ever have the experience of working on a site, working with MySQL and
then having something almost inexplicable happen?
I was working on a script, and had this weird event. A very simple script
with this:
mysql_connect("localhost","user","pass");
mysql_select_db("dbname")
or die("Query Connection Database failed");
$old=date("z")-1;
mysql_query("DELETE FROM Users WHERE Date < $old");
$cartquery = mysql_query("SELECT CartItemsID,Date FROM CartItems")
or die("Query failed");
$cartnow = mysql_query($cartquery);
$cr=0;
$cartme = mysql_num_rows($cartnow); <<<<this is the line that is failing!
while ($cr < $cartme){
$cartrow=mysql_fetch_row($cartnow);
$CII=$cartrow[0];
$CDa=$cartrow[1];
$pieces=explode(":",$CDa);
$DCHK=$pieces[1];
if ($DCHK < $old) {
mysql_query("DELETE FROM CartItems WHERE CartItemsID = '$CII'");
}
}
Started spitting this error at me:
Warning: Supplied argument is not a valid MySQL result resource in (exact
location snipped)
This is the line containing mysql_num_rows that is getting this error.
Someone please tell me I'm missing something obvious! Yes, the connects to
MySQL database are fine. I can run the query right in phpMyAdmin with no
issues.
If mysql_num_rows returns 0, or empty, it shouldn't be complaining, should
it? It would just skip the loop, correct?
Thanks,
-Mike