Re: If a query fails?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi

there are several ways to test if the insert/delete/update worked - with
mysql the easiest way is to use mysql_affected_rows() which returns the
number of entrys added/deleted/changed. another way is just to test if the
query worked like
$res = mysql_query($qry);
if(!$res)
    die('There was an error: '.mysql_error().'</body></hmlt>');

the most complicated way i think is to make a select after you
added/deleted/updated something and test if the data availiable really is
the data you wanted to insert.

hope this helps?

.ma

Chris Payne <cjp@planetoxygene.com> wrote@10.05.2003 1:45 Uhr:

> Hi there everyone,
> 
> Probably something so simple i'll collapse with embarressment, just like with
> my spelling :-)  But a quick question, when you perform an update or insert
> etc .... operation on a MySQL Database, how do you find out if it was
> successful or failed, so you can display the correct output?  Currently if I
> add to a DB, for example, it goes to a page saying it updated successfully but
> without any error trapping, so even if it DIDN'T do it successfully it would
> still go to the next page.
> 
> Thanks for your help :-)
> 
> Chris


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux