PC Nerd Posted May 12, 2007 Share Posted May 12, 2007 hi guys.... i want to have a function, where i can go something liek: if mysql has error, { mysql_status_enable = 0; } this way, it would cancel all funtions and variables relying on anything to do with the database....... and even replace those values, with something like "ERROR" is there a function or a way to do this? PS im not looking for a simply or die(); statement thanks Quote Link to comment Share on other sites More sharing options...
taith Posted May 12, 2007 Share Posted May 12, 2007 <? function db_query($query){ global $dbdisable; if($dbdisable==1) return; $result=mysql_query($query) or $dbdisable=1; return $result; } ?> Quote Link to comment Share on other sites More sharing options...
chigley Posted May 12, 2007 Share Posted May 12, 2007 A simpler way without a function would be: <?php $query = mysql_query("SELECT * FROM table") or mysql_close(); ?> Quote Link to comment Share on other sites More sharing options...
taith Posted May 12, 2007 Share Posted May 12, 2007 that works too... lol... Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted May 12, 2007 Author Share Posted May 12, 2007 so will mysql_close actually cancel all mysql stuff, or will the rest of the functions eg the rest of the queries, actually get a no connection error, or whatever.? thanks for your help, Quote Link to comment Share on other sites More sharing options...
chigley Posted May 12, 2007 Share Posted May 12, 2007 mysql_close closes the connection with MySQL so any future queries will not be able to run because there are no connection details availiable. Alternatively you can do this: <?php $query = mysql_query("SELECT * FROM table") or $error = true; /* Future queries... */ if(!$error) { $query2 = mysql_query("SELECT * FROM table2") or $error = true; } ?> Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted May 12, 2007 Author Share Posted May 12, 2007 ok, greatm thnks for your help.. is there any other way, to go it gloablly, like an event handeler or something liek: on mysqli_error() mysqli_ = 0; to cancel anything using mysqli_.......... if there is an error cauased by =it, and to possibly set it to mute "@" the error? cani do it that way? like in my ini file, or .htaccess on my login with my host etc.? thanks Quote Link to comment Share on other sites More sharing options...
taith Posted May 12, 2007 Share Posted May 12, 2007 i highly doubt it... Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted May 13, 2007 Author Share Posted May 13, 2007 ok, no problem, thanks anyway ill leave this open, in case anyone knows of a way to do it. Quote Link to comment 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.