hadeosdin Posted August 20, 2010 Share Posted August 20, 2010 Hello, i am trying to create a simple funtion that i can all upon to "turn off a website" i am calling the function by <?php siteonline(n); ?> and the function is function siteonline($msg){ $offlinecheck = mysql_query("SELECT * FROM acp") or die(mysql_error()); $siteoffline = mysql_fetch_array($offlinecheck); $ifsiteoffline = $siteoffline['site_offline']; $offline = $siteoffline['offline_msg']; if ($ifsiteoffline == "y") { echo("$offline"); die();} } now this will turn off the site but it shows no message what so ever and i can not figure out why can anyone help? Cheers, Quote Link to comment https://forums.phpfreaks.com/topic/211329-simple-functions-problem/ Share on other sites More sharing options...
Maq Posted August 20, 2010 Share Posted August 20, 2010 The way you're passing in 'n' is illegal in PHP. It's probably causing a fatal error and displaying a blank screen. In a development environment you should have error reporting displaying and set to max. Also, what's the point of passing in a parameter if you're not even using it in your method? Quote Link to comment https://forums.phpfreaks.com/topic/211329-simple-functions-problem/#findComment-1101899 Share on other sites More sharing options...
hadeosdin Posted August 20, 2010 Author Share Posted August 20, 2010 Can you think off a better way to do this then i need to check for site offline this is a Y for offline and a N for not and then if it is offline i need to call for the reason why. Quote Link to comment https://forums.phpfreaks.com/topic/211329-simple-functions-problem/#findComment-1101902 Share on other sites More sharing options...
Alex Posted August 20, 2010 Share Posted August 20, 2010 You're not even using $msg in the function, so why are you passing in that parameter? Just remove it. function siteonline(){ siteonline(); I doubt that's your problem though. More likely than not it's just throwing an undefined constant warning and assuming string "n". Are you sure that $offline contains what you're expecting? Quote Link to comment https://forums.phpfreaks.com/topic/211329-simple-functions-problem/#findComment-1101904 Share on other sites More sharing options...
Maq Posted August 20, 2010 Share Posted August 20, 2010 Can you think off a better way to do this then i need to check for site offline this is a Y for offline and a N for not and then if it is offline i need to call for the reason why. I'm really not sure how you're trying to achieve this. Do you have the status of the site stored in the DB? If that's the case, then you would want to pass in the site's name (or however you're going to reference it) and use it in the query by adding a conditional WHERE clause so you can extract the specific data for that site. You should also be returning a boolean as to whether or not it's online. Quote Link to comment https://forums.phpfreaks.com/topic/211329-simple-functions-problem/#findComment-1101909 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.