Damn! I should have seen that!
Oh well, at least it was something obvious. ;-) Thanks to you Jason, and everyone who replied to point out the obvious to my tired brain (excuses, excuses!). -Mike > -----Original Message----- > From: Jason Young [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, October 08, 2002 4:15 PM > To: [EMAIL PROTECTED] > Subject: [PHP] Re: Weird, weird, weird! > > > You're doubling up on your mysql_query's .. the first one runs, and I > don't know the ins and outs of PHP, but the second mysql_query causes > the resource to not be available... had a similar problem recently. > > Take the mysql_query out of the $cartquery assignment. > > -Jason > > Mike At Spy wrote: > > 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 > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php