Re: Weird, weird, weird!

From: Date: Tue, 08 Oct 2002 20:28:17 +0000
Subject: Re: Weird, weird, weird!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-119332@lists.php.net to get a copy of this message
To reitterate what Jason said, this is assignment is invalid. --- $cartquery = mysql_query("SELECT CartItemsID,Date FROM CartItems"); $cartnow = mysql_query($cartquery); ---- $cartnow will contain FALSE. And mysql_num_rows(false) will give the error you are recieving. -Keivn ----- Original Message ----- From: "Mike At Spy" <spycobalt@spyproductions.com> To: <php-general@lists.php.net> Sent: Tuesday, October 08, 2002 2:13 PM Subject: [PHP] Weird, weird, weird! > > 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 > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#119332) next »