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 Link to comment https://forums.phpfreaks.com/topic/51049-a-mysql-skip-function/ 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; } ?> Link to comment https://forums.phpfreaks.com/topic/51049-a-mysql-skip-function/#findComment-251223 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(); ?> Link to comment https://forums.phpfreaks.com/topic/51049-a-mysql-skip-function/#findComment-251234 Share on other sites More sharing options...
taith Posted May 12, 2007 Share Posted May 12, 2007 that works too... lol... Link to comment https://forums.phpfreaks.com/topic/51049-a-mysql-skip-function/#findComment-251237 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, Link to comment https://forums.phpfreaks.com/topic/51049-a-mysql-skip-function/#findComment-251359 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; } ?> Link to comment https://forums.phpfreaks.com/topic/51049-a-mysql-skip-function/#findComment-251360 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 Link to comment https://forums.phpfreaks.com/topic/51049-a-mysql-skip-function/#findComment-251370 Share on other sites More sharing options...
taith Posted May 12, 2007 Share Posted May 12, 2007 i highly doubt it... Link to comment https://forums.phpfreaks.com/topic/51049-a-mysql-skip-function/#findComment-251381 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. Link to comment https://forums.phpfreaks.com/topic/51049-a-mysql-skip-function/#findComment-251676 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.