RE: [PHP] sql query successful

From: Date: Wed, 18 Jul 2001 18:53:46 +0000
Subject: RE: [PHP] sql query successful
Groups: php.general 
Request: Send a blank email to php-general+get-58513@lists.php.net to get a copy of this message
> -----Original Message----- > From: Tyler Longren [mailto:tyler@captainjack.com] > Sent: Wednesday, July 18, 2001 1:36 PM > To: Mark Roedel; php-general > Subject: Re: [PHP] sql query successful > > > What about when DELETING from a table??? It always returns true. > Example...the highest ID in this table is 10: > > <? > if ($connection = mysql_connect("localhost","mysql","mysql")) { > print "Connection established"; > $db = mysql_select_db("aanr", $connection); > if ($sql = mysql_query("DELETE FROM bullitens WHERE > id='1212'")) { > print "Successful"; > } > else { > print "Not successful."; > } > } > else { > print "Connection NOT established."; > } > ?> > > We try to delete the bulliten with id of 1212, but there is > not bulliten with that ID, and it says "Successful". > > I know I could use mysql_affected_rows(), but why doesn't this work??? Because the query itself is still valid. No syntax errors, no connection errors, etc. The fact that there wasn't any data that needed to be deleted doesn't affect the validity of the query; just the results of it. Basically, what it boils down to is that "There wasn't anything for me to do" is not an error. It's a perfectly valid result. :) --- Mark Roedel (roedelm@letu.edu) || "There cannot be a crisis next week. Systems Programmer / WebMaster || My schedule is already full." LeTourneau University || -- Henry Kissinger

« previous php.general (#58513) next »