July 17th, 2000, 06:52 PM
I am developing a web site that makes use of the mysql php functions to get data from a database. If for some reason any of the calls to the db fails or the database is not available of whatever, i want to direct the user to a generic page saying something like "there was a database error. try again later." I dont want them to see the debugging information with the code that failed. how do i do this?
July 18th, 2000, 03:09 AM
I would suggest doing something like this
mysql_query($query) or die(DoSomething());
basically each time you do something database related you could just perform an or die() function, if it fails you could just output your generic error page, or whatever you wanted.
July 18th, 2000, 03:12 AM
I think you could also place a header() call inside the die() function that would take the misfotunate user to a pre-made error page.
Just one thought, though. If you are going to make your own die() function, be sure to set the last command in the function to exit because otherwise the script will continue running...
[This message has been edited by dwarf (edited July 18, 2000).]