Re: error handling in query execution

From: Date: Fri, 04 Mar 2005 09:00:02 +0000
Subject: Re: error handling in query execution
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-38764@lists.php.net to get a copy of this message
Chenri wrote:
i have a script that update records with this construct: while( .... ){
     query_string='UPDATE  .......';
     updateRecord(query_string);
} the problem is when there are wrong query_string (such as incorect syntax) can i make sure that the other query, the next one after the wrong query still goes. I've read about the @ operand but i still doesn't understand does the script stop when the error occured or does it still continue the process
Cherni, your updateRecord() function must handle the query error thats all. the '@' sign is there to repress errors so that they don't show up on screen or in your log. you may need to use the '@' to stop a warning from being emitted when you pass a bad query.... (you don't say which DB you use and I haven't used mysql in a long time) whether or not the script stops depends on what kind of error occurs. FATAL errors are exactly that, WARNINGs don't always need to be a show stopper it depends on your error checking/handling. to be honest though if you are buidling the SQL string then there is no reason for the SQL to be invalid. just make sure to check and sanitize all the variables you wan't to place inside the query (e.g. searching for name or selecting on id, etc)


« previous php.db (#38764) next »