Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am using PHP include code <?php if($page == "") { include "updates.txt"; } else { include "$page.txt"; } ?> on my website, http://www.animeplanetnet.net, and my host does support PHP, but whenever I click a link, it does not take you to the requested page, but simply stays on the main page. Can someone tell me what I am doing wrong?

I think the problem is in your use of the variable $page. You are using it correctly in the comparrison part of your if statement, but it is not correct in the include statement.
By including $page in quotes, it is no longer treating it as a variable. Instead you can try:
include $page.".txt";
I haven't tried combining strings within the include statement, si I'm not 100% sure if that will work, but if it doesn't then creating a single variable with the full page name first will. Such as:
$page = $page.".txt";
include ($page);I do something similar on one of my sites, but I use a Switch statement in my main page like this:
switch ($name) {
case "":
case "home":
$title = "Repeat Offenders";
$page = "home.php";
break;
case "downloads":
$title = "Repeat Offenders: Downloads";
$page = "downloads.php";
break;Then as I'm building the page I dynamically create the page title with the $title variable and call the content with the page variable using include($page)
Michael J

Sorry, my first ewxmple was missing hte parens. Should look like this:
include ($page.".txt");
Michael J

![]() |
html help!!
|
Rate my Website Layout
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |