467,174 Members | 1,358 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,174 developers. It's quick & easy.

php page will not process link to diff page

Hello PHPers,
I have just installed RH Linux ES 3.0 (basic) kernel 2.4.21-9.EL, i686,
Apache 2.0.X, and php 4.2.X. I have made no changes to the php.ini.

I am trying to use the following page (code listed here) to click on
link, and display 1 of three pages. The code does not seem to work, it
only shows the "else" condition of the php code, which is page:
"stuff.php". What do I need to do to my apache/php config to get this
to work??? Of course I copied this code from a php site tutorial somewhere.

Thanks,

eric

Page code below:
<?
if ($link == page2){
$page="files/page2.html";
}
elseif($link == page3){
$page="files/page3.html";
}
else{
$page="files/stuff.php";
}
?>
<html>
<head>
<title> index.php </title>
</head>
<body bgcolor="#999999">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td colspan="3"><h1>The Template (index.html)</h1></td>
</tr>
<tr>
<td align="center" valign="top"><a href="index.php?link=index">
Page 1 </a></td>
<td align="center" valign="top"><a href="index.php?link=page2">
Page 2 </a></td>
<td align="center" valign="top"><a href="index.php?link=page3">
Page 3 </a></td>
</tr>
</table>
<? include($page); ?>
</body>
</html>

Jul 17 '05 #1
  • viewed: 2393
Share:
3 Replies
"Eric W. Holzapfel" <e.****@verizon.net> wrote in
news:oN*****************@nwrddc02.gnilink.net:
I am trying to use the following page (code listed here) to click on
link, and display 1 of three pages. The code does not seem to work,
it only shows the "else" condition of the php code, which is page:
"stuff.php". What do I need to do to my apache/php config to get this
to work??? Of course I copied this code from a php site tutorial
somewhere. Page code below:
<?
if ($link == page2){
$page="files/page2.html";
}
elseif($link == page3){
$page="files/page3.html";
}
else{
$page="files/stuff.php";
}
?>
<html>


Where does $link get its value? Unless there's some other code you didn't
show that sets it, it's going to be NULL and therefore neither of the first
two comparison will succeed. Also, page2 and page3 really need to be
quoted in the comparisons.
Jul 17 '05 #2
Eric Bohlman wrote:
"Eric W. Holzapfel" <e.****@verizon.net> wrote in
news:oN*****************@nwrddc02.gnilink.net:

I am trying to use the following page (code listed here) to click on
link, and display 1 of three pages. The code does not seem to work,
it only shows the "else" condition of the php code, which is page:
"stuff.php". What do I need to do to my apache/php config to get this
to work??? Of course I copied this code from a php site tutorial
somewhere.


Page code below:
<?
if ($link == page2){
$page="files/page2.html";
}
elseif($link == page3){
$page="files/page3.html";
}
else{
$page="files/stuff.php";
}
?>
<html>

Where does $link get its value? Unless there's some other code you didn't
show that sets it, it's going to be NULL and therefore neither of the first
two comparison will succeed. Also, page2 and page3 really need to be
quoted in the comparisons.

Hello and Thanks, I "thought" that $link gets set by clicking on the
link on the index.php i.e. <href="index.php?link=page2"> Page 2 </a></td>
here I thought the $link gets the value "page2"??? Obviously I am
missing somthing (total beginner here!)
It is not clear to me how $link can get set.

Thanks for your help,
eric

Jul 17 '05 #3
Eric W. Holzapfel wrote:
Eric Bohlman wrote:
"Eric W. Holzapfel" <e.****@verizon.net> wrote in
news:oN*****************@nwrddc02.gnilink.net:
I am trying to use the following page (code listed here) to click on
link, and display 1 of three pages. The code does not seem to work,
it only shows the "else" condition of the php code, which is page:
"stuff.php". What do I need to do to my apache/php config to get this
to work??? Of course I copied this code from a php site tutorial
somewhere.

Page code below:
<?
if ($link == page2){
$page="files/page2.html";
}
elseif($link == page3){
$page="files/page3.html";
}
else{
$page="files/stuff.php";
}
?>
<html>


Where does $link get its value? Unless there's some other code you
didn't show that sets it, it's going to be NULL and therefore neither
of the first two comparison will succeed. Also, page2 and page3
really need to be quoted in the comparisons.


Hello and Thanks, I "thought" that $link gets set by clicking on the
link on the index.php i.e. <href="index.php?link=page2"> Page 2 </a></td>
here I thought the $link gets the value "page2"??? Obviously I am
missing somthing (total beginner here!)
It is not clear to me how $link can get set.

Thanks for your help,
eric

You should add this line to the top of the page (after the <?php) if you
want $link to contain the variable 'link' from the querystring:

$link = $_GET['link'];

You should also add single quotes ( ' ) around page2 and page3 in your
if statement.

Chris
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

21 posts views Thread by deko | last post: by
1 post views Thread by Cyril Vi?ville | last post: by
32 posts views Thread by sandy | last post: by
8 posts views Thread by Judy Ward | last post: by
1 post views Thread by ilario santamaria | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.