PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Except you really should not use die() for error handling. The code should check for errors and respond with a page with an error message, do a redirect, etc.
arborint wrote:Except you really should not use die() for error handling. The code should check for errors and respond with a page with an error message, do a redirect, etc.
Sorry, die was for testing/speed in response to your question. For real life you should develop a custom error handler (that does not repeat the mysql_error())..
arborint wrote:Except you really should not use die() for error handling. The code should check for errors and respond with a page with an error message, do a redirect, etc.
Now a question. I recently started throwing exceptions (of various types such as DBException, UserException etc..) that actually implement a template approach with a render() method. They look pretty. It's still an error dumped to screen but it looks nice and if you're logged in as a developer you even get a little geshi output with a code excerpt and the relevant line highlighted. Bad use of exception handling?
arborint wrote:Except you really should not use die() for error handling. The code should check for errors and respond with a page with an error message, do a redirect, etc.
You should also be wrapping the SQL statement in a transaction and rolling back after the failed statement.