ShoeLace1291 Posted January 15, 2008 Share Posted January 15, 2008 I have a database connection page included at the top of my main page. I was wondering if it were possible to cancel the execution of the rest of the page coding if an error occurs while connecting. If so, how would I do that? Quote Link to comment https://forums.phpfreaks.com/topic/86181-if-error-then-stop-loading/ Share on other sites More sharing options...
revraz Posted January 15, 2008 Share Posted January 15, 2008 Do a mysql_error() check and if it's present, redirect elsewhere. Quote Link to comment https://forums.phpfreaks.com/topic/86181-if-error-then-stop-loading/#findComment-440140 Share on other sites More sharing options...
p2grace Posted January 15, 2008 Share Posted January 15, 2008 Here's another really simple solution: $query = "SELECT ..."; $run = msyql_query($query); if($run){ // query success }else{ // query unsucessful die("Unable to connect to database. Error: ".mysql_error().""); } Quote Link to comment https://forums.phpfreaks.com/topic/86181-if-error-then-stop-loading/#findComment-440142 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.