[PHP-DB] error handling
hello, how can i use error_log( ) function to capture the error occured in my server, currently the Error warning is switched off and i can't turn it on because it is in production server the problem is the query miss some records, and i didn't see it's error message beside this code $err=mysql_query($string); if(!$err) { error_log(); } do i can get somekind of global error handling? Something that can catch an error anywhere in the codes, thx -- Chenri J Taman Palem Lestari B18 - 19A Mobile CDMA Esia: (62) (21) 926 68 651 Email: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Error handling
Hi, I'm new to PHP; I installed version 5.0.3 using Apache 2 and Postgres 8 on Win XP SP2. I have a connection class and one of its methods is: public function EjecutaSQL($pe_textoSQL = ) { return pg_query($this-id, $pe_textoSQL); } where $pe_textoSQL contains the SQL sentence. If after executing it there is a Constraint error sent by the DB for example, or a syntax error in the SQL statement, no error or warning is displayed in the browser, unless I use pg_last_error() and handle the error myself. I checked the PHP.ini and I have the parameter error_reporting = E_ALL Testing these examples on PHP 4, adjusting all the necesary code to run from 5 to 4, all warnings and errors are displayed as sent by PostgreSQL. Any help will be appreciated, Thanx Guillermo N -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] error handling in query execution
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) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] error handling with ms sql server (mssql) - insert and update unique indexes
sorry for posting this mail twice, but the first one doesn't appear on the news server (posting with google, doesn't work...) Hi, when I insert a new record with a unique indexed attribute, which is already in the table, I only get some php warnings: Warning: MS SQL message: Cannot insert duplicate key row in object 'user_profile' with unique index 'nickname'. (severity 14) in c:\web\register\register.php on line 81 Warning: MS SQL: Query failed in c:\web\register\register.php on line 81 I want to identify the error and do some special php functions. Unfortunately I don't get any message with mssql_get_last_message() and SELECT ERROR AS errorId always returns 0. changing the severity only gives different php warnings mssql_min_error_severity (0); mssql_min_message_severity (0); How do I fetch and handle INSERT INTO and UPDATE SET warnings. Is there any example on the internet? Thanks for your hints muhe -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Error handling with connection?
When a database connection fails, how do I detect that in my script so I can skip all the rest? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]