Error handling in PHP4 with MySQL
Posted: Sun Jul 26, 2009 10:30 pm
I am working in PHP4 (I know, 5 is better with try...catch but I can't help the PHP4 decision). Anyway, I need to make sure that if a MySQL query creates certain errors (no table by that name and no field by that name) that the rest of the script executes but I can let the user know that an error occurred. My code has an array of queries and if one of the queries has an error then the script stops and the error is displayed. Like this:
What recommendations do you all have to deal with the error but not kill the script?MySQL ERROR:
Error Number: 1054
Description: Unknown column 'field_name_test' in 'field list'
Query: INSERT INTO `exp_weblog_fields` (`field_name_test`) VALUES ('testing123')