Humpty Posted April 29, 2007 Share Posted April 29, 2007 G'day guys, I am using the following code: CODE 1 $ezusersSearchresult=mysql_query($ezusersSearchquery) or ("<BR><BR> SQL ERROR Getting Plan List 001:<BR>$ezusersSearchquery"); This has always done me fine right up until now. We are going to set this file (and others) as automatic cron jobs. I will need to use the following code if an error occurs. CODE 2 $AppendToERRORLog = "There was an error ERRORDETAILS WILL BE HERE"; include ("AppendERRORLog.php"); Now CODE 2 works just fine, what I can't work out is how to make it work instead of the message displayed if mysql_query doesn't work and errors for whatever reason. CODE 1 would display it on the screen (which was all well and good while i was manually running it). CODE 2 writes info to a txt file so that I can store it and check it at a latter date. Thanks in advance. - Humpty Link to comment https://forums.phpfreaks.com/topic/49151-solved-help-with-error-trapping-and-similar-phpmysql/ Share on other sites More sharing options...
trq Posted April 29, 2007 Share Posted April 29, 2007 <?php if (!$result = mysql_query($ezusersSearchquery)) { $AppendToERRORLog = "There was an error ERRORDETAILS WILL BE HERE"; include ("AppendERRORLog.php"); } ?> Link to comment https://forums.phpfreaks.com/topic/49151-solved-help-with-error-trapping-and-similar-phpmysql/#findComment-240835 Share on other sites More sharing options...
Humpty Posted April 29, 2007 Author Share Posted April 29, 2007 sweeeeeeeeet! That is exactly what I had been searching for. Thankyou, thankyou and thanks. Now by the same token what happens there is if it is succesfull my $result is the same as it would have been my (less helpful, more amature) original way correct? Link to comment https://forums.phpfreaks.com/topic/49151-solved-help-with-error-trapping-and-similar-phpmysql/#findComment-240848 Share on other sites More sharing options...
trq Posted April 29, 2007 Share Posted April 29, 2007 Now by the same token what happens there is if it is succesfull my $result is the same as it would have been my (less helpful, more amature) original way correct? Correct. PS: (Answering one of the questions in your sig) The solved button is in the lower left corner of the thread. I'll mark this one resolved. Link to comment https://forums.phpfreaks.com/topic/49151-solved-help-with-error-trapping-and-similar-phpmysql/#findComment-240865 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.