Re: [PHP] mysql_error() problem?
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. Thanks! Tyler - Original Message - From: "CPT John W. Holmes" <[EMAIL PROTECTED]> To: "Tyler Longren" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Wednesday, August 06, 2003 3:35 PM Subject: Re: [PHP] mysql_error() problem? > From: "Tyler Longren" <[EMAIL PROTECTED]> > > 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... > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_error() problem?
From: "Tyler Longren" <[EMAIL PROTECTED]> > 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... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_error() problem?
* Thus wrote Tyler Longren ([EMAIL PROTECTED]): > 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." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysql_error() problem?
Hi, 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? Thanks, Tyler -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysql_error problem
I am using the below function (error_db) witch is called thus:- function query_db( $sql, $db ) { $result = mysql_query( $sql, $db ) or error_db( $sql, $db ); return $result; } But $sqlerr is always blank (it is set with '$sqlerr = mysql_error( $db );'). Any idea why? Ben function error_db( $sql, $db ) { global $SERVER_NAME; global $SCRIPT_NAME; table_top( "Database Error" ); table_middle(); $sqlerr = mysql_error( $db ); echo "SQL::$sqlError:$sqlerr"; table_bottom(); // Clost of table/html from calling script table_bottom(); html_footer(); // Send error via email $msg = "Database error has accured on $SERVER_NAME\n\n.". "The error message is :-\n\n". "SQL:$sql\n\nError:$sqlerr\n\n". "This message was ". "generated by '$SERVER_NAME$SCRIPT_NAME'"; $subj = "Database error from $SERVER_NAME"; // Hard coded to minimize chance of this module erroring $to = "[EMAIL PROTECTED]"; $from = "From: ".$to; mail( $to, $subj, $msg, $from ); die(); } * Ben Edwards Tel +44 (0)1179 553 551 ICQ 42000477 * * Homepage - nothing of interest here http://gurtlush.org.uk * * Webhosting for the masses http://www.serverone.co.uk * * Critical Site Builderhttp://www.criticaldistribution.com * * online collaborative web authoring content management system * * Get alt news/views films online http://www.cultureshop.org * * i-Contact Progressive Video http://www.videonetwork.org * * Fun corporate graphics http://www.subvertise.org * * Bristol Indymedia http://bristol.indymedia.org * * Bristol's radical news http://www.bristle.org.uk * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php