My classifieds website uses mainly PHP and MySql.
On error, (for example if a variable isn’t found), I would like to have an error-page to show, is this possible? And I mean for every error to point to the same error-page.
I am thinking about htaccess, but maybe there are other ways also?
Same with MySql, how is it done there?
Thanks
Personally, I use error exceptions all the time (http://us.php.net/manual/en/class.errorexception.php)…
So, at the beginning of my code, I have the following:
Then, I wrap everyting in a giant try{}catch{} block. So I can “catch” the error higher, but if I don’t, it displays an error message to the client:
The beauty is that it’ll catch ANY kind of error. So in my DB class, I simply throw a DatabaseException (which extends Exception). So I can try/catch for that when I make my call if I want to fail gracefully, or I can let it be handled by the top try{}catch block.