You now have a complex mechanism in place to deal with error messages as they crop up, and you even have a way of printing out errors for your programming edification (with debug_print). Now, it’s time to see how to use the error information. Take a look at one of your simplest page/script combinations: connection.html and connect_php.
Update connect.php to show_user.php
Right now, correct.one just uses die to report problems in connecting to your database:
Right now, if my sql_ connect fails, the entire script just goes down in a ball of flames. Not so great. One way you could fix the problem would be to do something like this:
This example uses your new error page in conjunction with PHP’s redirect. In addition, it supplies both a friendly and system-level error, so it should work pretty well. For the sake of testing, type in a bad database host. like this one:
Next, go to Connect.html in your browser, submit the form to connection.php and you should be rewarded with your error page, as in Figure 8-12. In terms of seeing errors, you have your users-and yourself-covered.
Now, set DEBUG_MODE to false in app.config.php:
// Set up debug mode
define(DEBUG_MODE”, false);
Try going to connect.tum! and connect.php again; this time, you should only see the user-facing error (check out Figure 8-13) .