> -----Original Message-----
> From: Tyler Longren [mailto:[EMAIL PROTECTED]]
> 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 ([EMAIL PROTECTED])  ||  "There cannot be a crisis next week.
Systems Programmer / WebMaster  ||   My schedule is already full."
     LeTourneau University      ||                    -- Henry Kissinger


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to