PDA

View Full Version : PHP problems getting annoying...


Ryan Ashbrook
06-11-2004, 09:24 PM
I'm recoding my site, and I have it so that based on a certain condition the content changes from one include of a .htm file to another include.

Well, I get sorta what I want, but when I try to go to a page other than the index, one page just shows up for them all.

Like if I go to www.domain.com/index.php?page=aff_apply the affiliation page shows, but if I go to www.domain.com/index.php?page=staff the affiliation page still shows.

It's probably something in my coding...

You can look for your self here: www.theglassprison.net click on any link that has ?page= in it, and you'll be taken to the affiliation page.

Here's the code I'm using...

if (!$page)
{
$content = './news.htm';
}
else
if ($page="aff_apply")
{
$content = './aff_apply.htm';
}
else
if ($page="fanart")
{
$content = './fanart.htm';
}
else
if ($page="fanfiction")
{
$content = './fanfic.htm';
}
else
if ($page="host_apply")
{
$content = './host_apply.htm';
}
else
if ($page="staff")
{
$content = './staff.htm';
}
else
if ($page="wallpaper")
{
$content = './wallpaper.htm';
}

I really need help on this...

ViaraiX
06-11-2004, 09:55 PM
try changing

else
if (...

to

elseif (...

filburt1
06-11-2004, 10:02 PM
try changing

else
if (...

to

elseif (...
Don't use = when comparing items. Use the comparison operator ==. Right now every condition you have returns true.

filburt1
06-11-2004, 10:04 PM
BTW, you can optimize that down to two statements:


$pages = array
(
"" => "news",
"aff_apply" => "aff_apply",
"fanart" => "fanart",
"fanfiction" => "fanfic",
"host_apply" => "host_apply",
"staff" => "staff",
"wallpaper" => "wallpaper"
);
$content = $pages[$page];

Ryan Ashbrook
06-11-2004, 10:15 PM
BTW, you can optimize that down to two statements:


$pages = array
(
"" => "news",
"aff_apply" => "aff_apply",
"fanart" => "fanart",
"fanfiction" => "fanfic",
"host_apply" => "host_apply",
"staff" => "staff",
"wallpaper" => "wallpaper"
);
$content = $pages[$page];

Oh heh, thanks filburt. ^_^