Forum Moderators: coopster
[ BEGIN CODE ]
<?
if ($link == page2){
$page="pages/page2.html";
}
elseif($link == page3){
$page="pages/page3.html";
}
else{
$page="pages/page1.html";
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="maincss.css">
<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=page1"> 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>
[ END CODE ]
[ BEGIN ERRORS ]
Notice: Undefined variable: link in c:\inetpub\wwwroot\TMPhs2k8usl8o.php on line 2
Notice: Use of undefined constant page2 - assumed 'page2' in c:\inetpub\wwwroot\TMPhs2k8usl8o.php on line 2
Notice: Undefined variable: link in c:\inetpub\wwwroot\TMPhs2k8usl8o.php on line 5
Notice: Use of undefined constant page3 - assumed 'page3' in c:\inetpub\wwwroot\TMPhs2k8usl8o.php on line 5
Warning: main(pages/page1.html): failed to open stream: No such file or directory in c:\inetpub\wwwroot\TMPhs2k8usl8o.php on line 35
Warning: main(): Failed opening 'pages/page1.html' for inclusion (include_path='.;c:\php4\pear') in c:\inetpub\wwwroot\TMPhs2k8usl8o.php on line 35
[ END ERRORS ]
Regards,
Wallie, NEWBIE
The sole reason for all of your erros on this page is because the first time you load this page the variables are unset. So you need to do the following:
<?
if (isSet($link)){if($link == 'page2'){
$page="pages/page2.html";
}
elseif($link == 'page3'){
$page="pages/page3.html";
}
else{
$page="pages/page1.html";
}
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="maincss.css">
<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=page1"> 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>
You should now be ready to rock and roll! HTH
mbcx9rvt
It's often nicer to us <?php code here ?> instead of <? ?> - it's easier to read and I'm sure there will be some techno mumbo jumbo about some browsers liking the language defined.
Try using:
<style type="text/css" media="screen">@import "main.css";</style>
when you import your external stylesheets.
Good luck and HTH,
mbcx9rvt
[ ERRORS ]
Notice: Undefined variable: page in c:\inetpub\wwwroot\index.php on line 32
Warning: main(): Failed opening '' for inclusion (include_path='.;c:\php4\pear') in c:\inetpub\wwwroot\index.php on line 32
[ CODE ]
<?
if (isSet($link)){
if($link == 'page2'){
$page="/page2.htm";
}
elseif($link == 'page3'){
$page="/page3.htm";
}
else{
$page="/page1.htm";
}
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="maincss.css">
<title> index.php </title>
</head>
<body bgcolor="#FFFFFF">
<table width="25%" align="center" cellpadding="0" cellspacing="0" border="0">
<tr>
<td colspan="3" align="center" height="50"><font face="Verdana, Arial, Helvetica, sans-serif" size="3">The Template (index.html)</font></td>
</tr>
<tr>
<td align="center" valign="top"><a href="index.php?link=page1"> 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>
[ page1.htm ]
<table>
<tr>
<td><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000">This Should Be Page 3</font></td>
</tr>
</table>
If it is not that you need to do some debugging.
Replace the include() statement with a print("test"); statement. if "test" is printed then you know your script is working up to that point. If nothing is output then you know you have an issue earlier on in your script.
Im sorry my responses are slow but I am away from my PC most of this week. I'm glad I've helped so fa.r If you like, print your whole code in your next post and I will see what I can do. Also, tell me what the response is from the test as described above.
Good luck,
mbcx9rvt
Do these files exist? If nothing is output then chances are the files don't exist as we haven't told it to do anything upon these files not existing - only for it to do something if they do exist.
Double check that you have your links correct in your $page variables! i.e. do you mean pages/page2.html or simply /page2.html
HTH
mbcx9rvt