Jump to content

Simple functions problem!


hadeosdin

Recommended Posts

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,

 

Link to comment
https://forums.phpfreaks.com/topic/211329-simple-functions-problem/
Share on other sites

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?

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?

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.