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? 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. 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().""); } 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
Archived
This topic is now archived and is closed to further replies.