MyBB Community Forums

Full Version: What is wrong with this if function?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey guys, does anybody know what is wrong with this:

$page = $_GET['page'];
if ($page = "")
{
	$page = "index";
}
else if ($page != "")
{
	$page = $page;
}

$pagepath = "pages/".$page.".php";
include $pagepath;

when i type:
http://mysite.com/directoy/index.php?page=test

Warning: include(pages/.php) [function.include]: failed to open stream: No such file or directory in /home/xxxxxx/public_html/directory/index.php on line 21

As you can see it doesnt see the page name :/
(BTW: line 21 is the include line XD)

Thanks
$page = $page is unnecessary, so you can scratch the else if.

also the first if should probably be == not =
Thanks that fixed it Smile