hello,
i have a website that runs a query on a database when you select a certain to and from date. sometimes if you try and bring back too much information in one go i get this error, Fatal error: Maximum execution time of 30 seconds.
the problem i have is that the form for setting the date appears below the call to the database so when this error occurs the form does not get printed and the user is left with this error and no way to key in a smaller time frame.
has anyone any ideas?
help much appreciated.
How to catch an Sql Error
Moderator: General Moderators
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: How to catch an Sql Error
If you are calling the form on itself ($_SERVER['PHP_SELF']) , do a simple check whether or not the submit button has been set. If the submit button has been clicked, display the form again THEN run the code that does the search against the database. The else statement will be executed if the button has not been clicked, and the form is displayed as normal. This will also work if you don't call the form on itself you just have to modifiy the code on the process page to include the form again, along with the results of the query.
Code: Select all
<?php if isset($_POST['submitButtonName']) {
// display the form again
//code that does the checking
}
else {
// if this part of the execution is reached, it means the form
// has not been submitted, thus display the form
}
?>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering