Parse error: parse error, unexpected T_SWITCH

LuxHost

New member
I am trying to get my personal site coded through PHP navigation, but I get this error:

Parse error: parse error, unexpected T_SWITCH

This is the code that I am using:

PHP:
<? php
switch($page){ // where it says $page you can have whatever you want e.g $p or $pid
default:
include('index.php'); // This is the default page that you want users to see
break; // Ends the default page
/* case "other_page": change what's inside the quotes to whatever your page will be called */
case "girl":
include('girl.php'); // Your other pages use this method.
break;
case "boy":
include('boy.php');
break;
case "site":
include('site.php');
break;
case "other":
include('other.php');
break;
case "poems":
include('poems.php');
break;
case "exit":
include('exit.php');
break;
case "host":
include('host.php');
break;
}
?>

Can someone please help me?
 
There is a much easier way to do this.

Give me a few mins, and I'll create and attach an easier method for you.
 
Here you go.

You would call this, exactly the same something.php?page=girl etc

PHP:
<?php

$pages = array("girl" => "girl.php", 
"boy" => "boy.php", 
"site" => "site.php", 
"other" => "other.php",
"poems" => "poems.php",
"exit" => "exit.php",
"host" => "host.php");
	       
if(isset($HTTP_GET_VARS['page']))
{
	$src = $pages[ $HTTP_GET_VARS['page'] ];
}
else
{
	$src = "index.php"; # This is the default page to be loaded if no 
			     # Page has been selected (i.e. there's no 'page' component of the query string)
}

include("$src");

?>
 
Thank you for the code, but its still not working.

here is the link:

http://70.85.5.194/~roxanne/

If you look at the table, "Navi", those are all the pages that I want to be linked.

$src = "index.php"; -- I dont know what to put as the src. I changed it to "default.php", but it still isnt working. Do you know how to fix this problem?
 
When I click on anything but the girl link, I get:
Warning: main(poems.php): failed to open stream: No such file or directory in /home/roxanne/public_html/index.php on line 21

Warning: main(): Failed opening 'poems.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/roxanne/public_html/index.php on line 21

This is telling me that the files it's asking for, are either in the wrong directory, or simply do not exist.
 
Back
Top