php problems

Soldato
Joined
12 Nov 2004
Posts
2,527
Location
Bath
Hi all,
I have been using this script fine up till now, al of a sudden it doesn't seem to be working... I am try to get a php page to appear in anouther php, this is the script:

PHP:
<?php
if (! file_exists("$page.php"))
{
include("news.php");
}
else
{
include("$page.php");
} ?>

when you click something on the menu bar it sends you to index.php?page=(page name here), eg. to get to the links.php page to appear it would be index.php?page=links

Now all that seems to be happening is news.php is only being displayed, is there any reason for this?
Thanks!
 
Your host has turned off register_globals. Add:

Code:
$page = $_GET['page'];

to the top of your script. Consider also working in something against recursive includes.

fluiduk said:
why do you have $page inside speech marks?

Wouldnt that stop it working?

No.
 
Ah i just tried this
PHP:
<?
if(!$_GET['id'])
$_GET['id'] = "news";

if(file_exists($_GET['id'].'.php'))
include($_GET['id'].'.php');
else
include("news.php");
?>

Which seems to be working fine (just uses ?id=)... Thanks anyway :)
 
Back
Top Bottom