Tyler Longren pressed the little lettered thingies in this order...

> 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???
> 

mysql_query() is not intended to be used as a means by which you can 
check the number of rows that are affected.  If it returned FALSE severy 
time your query was empty, you would have to rewrite all of your of code 
to eliminate errors.  It only checks for the validity of your query.

To ask why this doesn't work would be the same thing as asking why 
you can type this query from the command-line mysql client and the 
query succeeds without an error. It succeeds and says "0 rows."

It's a valid query with zero results.  A FALSE return from a programming 
function indicates an error condition, not the lack of results.

Christopher Ostmo
a.k.a. [EMAIL PROTECTED]
AppIdeas.com
Innovative Application Ideas
Meeting cutting edge dynamic
web site needs since the 
dawn of Internet time (1995)

For a good time,
http://www.AppIdeas.com/

-- 
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