Hi All
How do I know if my update statement was successful when updating my database using php. I am working with php5 and mysql
Regards
Antek
How do I know if my update statement was successful
Moderator: General Moderators
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
update statement could be successful without any rows being updated, for example:malcolmboston wrote:mysql_affected_rows
Code: Select all
update table set column=123 where 2<1Well for a start, mysql_query() will not return false.. that proves it was a 'successful' statement, and mysql_affected_rows() returns how many rows were updated, this proving the criteria was correct/incorrect.
Using a bit of common sense you can work out if the intended results match the actual results..
Using a bit of common sense you can work out if the intended results match the actual results..
Last edited by Jenk on Mon Oct 10, 2005 8:06 am, edited 1 time in total.
Code: Select all
mysql_query("UPDATE `table` SET `forks` = 4 WHERE `forks` < 4") or die("An error occurred");