Page 1 of 1

Help with non functioning IF statement

Posted: Fri May 07, 2010 10:18 am
by braatenj
Ok, so I am just playing around a little bit trying to learn PHP & MySQL and I am trying to create a very small forums, now the bulk of the forum code is run from IF statements in the index.php file. Now I have these two IF statements

Code: Select all

if ($fid == ''){
//show the different forums
} elseif ($fid != '' && act =='0'){
//show the posts in the selected forum
}
now when the page is first viewed it shows the different forums, which it is supposed to do, however when you click the link for one of the forums and the url reads index.php?fid=1&act=0 it is still executing the code inside the first IF statement instead of the second one, I don't understand why it is not behaving the way it is intended to, any help would be appreciated.

Re: Help with non functioning IF statement

Posted: Fri May 07, 2010 10:33 am
by AbraCadaver

Code: Select all

echo $fid;
echo $acct;
Then read up on http://www.php.net/manual/en/reserved.variables.get.php

While learning you need this:

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors', '1');

Re: Help with non functioning IF statement

Posted: Fri May 07, 2010 11:05 am
by braatenj
Ahh, I thought that the variables that were passed through the links where automagically recognized with their corresponding name, didn't realize I had to $_GET them first :)

Re: Help with non functioning IF statement

Posted: Fri May 07, 2010 1:44 pm
by AbraCadaver
braatenj wrote:Ahh, I thought that the variables that were passed through the links where automagically recognized with their corresponding name, didn't realize I had to $_GET them first :)
http://php.net/manual/en/security.globals.php