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
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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.