This is a discussion on Re: [PHP] mysql_error() problem? within the PHP General forums, part of the PHP Programming Forums category; From: "Tyler Longren" <tyler@jdhost.com> > I'm running an UPDATE query on my table. ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
From: "Tyler Longren" <tyler@jdhost.com>
> I'm running an UPDATE query on my table. After executing the query, I check > mysql_error() to see if there's any errors: > if (mysql_error() == "") { > // success > } > else { > // failure > } > > mysql_error() is always empty even if the query didn't succeed. So it > always thinks it succeeds. I remember having this problem once quite a > while ago. I remember somebody telling me that it had something to do with > UPDATE. Is there a better way to check for errors? Please define "didn't succeed"... There is a difference between the query "generated an error" which is caught with mysql_error() and the query "did not affect any rows" which is caught by mysql_affected_rows(). ---John Holmes... |
|
|||
|
* Thus wrote Tyler Longren (tyler@jdhost.com):
> hmmm...perhaps that was it. When I had this issue before, someone told me > to check mysql_affected_rows() when using issuing an UPDATE query. I'll > give that a shot. Correct, mysql_affected_rows() on a query that doesn't return rows (insert, update, delete) and use mysql_num_rows() for a select query. Curt -- "I used to think I was indecisive, but now I'm not so sure." |
|
|||
|
--On Wednesday, August 06, 2003 13:11:52 -0700 "Chris W. Parker" <cparker@swatgear.com> wrote: > Aside from the fact that $example1 != $example2, they are different in > ATTITUDE. > Which was the original issue of this thread. Seems like few (with a temporary advantage of knowledge) would consider not to have an attitude (don't like to answer, don't do it) and if there is a choice, the nasty one seems to prevail. I guess it's a reflection of the times/place we are living or a huge lack of imagination. My last word on this... Andu |