• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net

What is wrong with my code?

The Wolf

New Member
Hey guys,
now.... im pretty sure i did it right but it just won't die like it should

//Website Offline Mode
$WebOffline[Enabled] = "True";
$WebOffline[IsPass] = $_GET[Over];
$WebOffline[Pass] = "TEST";
if ($WebOffline[Enabled] == "True" && $WebOffline[IsPass] != "$WebOffline[Pass]"){
// die("Offline Test");
}else {
//do otherwise


Active Member
You missed the closing bracket on the else portion of the if-else statement. I don't have a huge amount of experience with PHP, but I seem to recall quotes needed around the indices of associative arrays (ie: $WebOffline["Enabled"] instead of $WebOffline[Enabled]). And to AboutWeb: php doesn't have an "endif" thing required.

I'm not sure why you put quotes around "True" because PHP can do boolean data types (and it's faster than having to compare strings). I'm also not sure why you put quotes here:

$WebOffline[IsPass] != "$WebOffline[Pass]"

because that will just evaluate the value of $WebOffline[Pass] and return that as a string; You might as well just leave the quotes out.

Debugging PHP is a lot easier with an IDE (integrated development environment) of some sort. About the most simple it gets is Notepad++. It'll let you know about syntax errors with your code, like the missing closing bracket or missing quotes. An even better IDE is Netbeans, which will tell you about errors with syntax and waay more. If you go the Netbeans route, you might need to install PHP on your local machine (not sure if it's needed or not), which I found was easiest using XAMPP (which will also give you Apache and MySQL, letting you test your PHP scripts locally).

Oh, also an incredible source for PHP reference notes: http://www.tuxradar.com/practicalphp
Beats all the other tutorial/reference sites I've found on PHP yet.
Last edited:


Active Member
So you mean if he put "else {}" everything will be fine ?

At least it'll run that way. He might get some sort of error about undefined variables because of the lack of quotes around indices on his arrays, but it'll at least try to run the script.

The Wolf

New Member
It is not an array it is just how the variable is written, and yes i'm pretty sure its because the die is commented lmao i can not believe i missed that.