Forum Moderators: coopster

Message Too Old, No Replies

Parse error: parse error, unexpected T VARIABLE in C:\ukkonkans\ukkonk

T_VARIABLE error message

         

mvaz

11:30 pm on Feb 4, 2008 (gmt 0)

10+ Year Member



I am testing on my local host, and I encounter the above error when loading/viewing index.php. The code is as below:

<?php
$p = $_GET['page'];
if(strpos($p, "..")) {
die ("Bad page request");
}
if (!$p) $p = "main";
$content_file=$_SERVER['DOCUMENT_ROOT']."/". $p. ".php";
if (!file_exists($content_file)) {
header("Location:" $_SERVER["PHP_SELF"]});
exit();
}
$title = ($p)? "$p - My Site!" : "Main page - My Site!";
include_once("topbit.php");
include_once($content_file);
include_once("bottombit.php");

?>

I think this has got something to do with the redirection element, but for the life of me, I couldn't get it right. What I am trying to do here is, if $content_file does not exist, I want the visitor to be redirected to the home page.

phparion

5:26 am on Feb 5, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



header("Location:" $_SERVER["PHP_SELF"]});

extra brace

header("Location:" . $_SERVER["PHP_SELF"]);

use the above.. btw i discourage you using PHP_SELF .. hard code your page name or store the name in a variable and use it.