A litte help please...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
B17BR34K
Forum Newbie
Posts: 3
Joined: Fri Mar 20, 2009 11:16 am

A litte help please...

Post by B17BR34K »

I'm trying to make a simple link system on my website. My friend had coded this previously and it worked. I basically tried to recode it myself with a little help from him over a chat session and for some reason it's just not working. If someone could help point out what I'm doing wrong, I would appreciate it very much.

$page = 'home.php';
$link = 'home'; <====== was $_GET['home.php']; but I changed it.

if ($link == 'home'){
$page = 'home.php';
}

if ($link == 'links'){
$page = 'links.php';
}

if ($link == 'about'){
$page = 'about.php';
}

include $page;


It's not giving me any errors... It's just not pulling up the content from the other php files. Maybe I should change the page= to use the $_GET variable?
temidayo
Forum Contributor
Posts: 109
Joined: Fri May 23, 2008 6:17 am
Location: Nigeria

Re: A litte help please...

Post by temidayo »

try putting double quote around the variable in front of the include like this:

Code: Select all

include "$page";
B17BR34K
Forum Newbie
Posts: 3
Joined: Fri Mar 20, 2009 11:16 am

Re: A litte help please...

Post by B17BR34K »

Actually I forgot to mention that that's probably the only thing that works. It's including the home page, the links just aren't changing to the content that I have in the other php files.

<a href="test.php?link=home">HOME</a><br />
<a href="test.php?link=links">LINKS</a><br />
<a href="test.php?link=about">ABOUT</a>

Those are the links I'm using. The php files are located in the same directory as test.php.
temidayo
Forum Contributor
Posts: 109
Joined: Fri May 23, 2008 6:17 am
Location: Nigeria

Re: A litte help please...

Post by temidayo »

what you are suppose to do then is

Code: Select all

$link = $_GET['link'];
Put that code at the very line you changed.
B17BR34K wrote: $link = 'home'; <====== was $_GET['home.php']; but I changed it.
B17BR34K
Forum Newbie
Posts: 3
Joined: Fri Mar 20, 2009 11:16 am

Re: A litte help please...

Post by B17BR34K »

temidayo

Thanks, that fixed the problem. I guess my friend didn't remember how he had coded it the first time. :D
temidayo
Forum Contributor
Posts: 109
Joined: Fri May 23, 2008 6:17 am
Location: Nigeria

Re: A litte help please...

Post by temidayo »

You are welcome!
Post Reply