Jump to content


im getting this error and cant seem to get it fixxed


5 replies to this topic

#1 zetsumei

    Young Padawan

  • Publishing Betazoids
  • Pip
  • 269 posts
  • Gender:Male
  • Location:127.0.0.1

Posted 14 August 2006 - 09:47 PM

the error im getting is
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/concept/public_html/admin/index.php on line 50

heres my php code
<?php
   $val = $_GET['id']; // Replace id with whatever you want to use, eg ?id=page
   $val .= '.php'; // Makes the filename complete so if you called ?id=index, it would be index.php it has to look for
   $dirty = array('..');
   $clean = array('');
   $val = str_replace($dirty, $clean, $val); // Prevent people from viewing root files like your password (should work i just quikly added it without testing)
   
   if(isset($_GET['id'])){ // Replace id with whatever you want to use, eg ?id=page
	if(file_exists($val)){ // This checks if the file you are trying to call exists
	include '$val';
	}
	else{
	 include '404.php'; // If the file doesnt exists it calls your 404 error page
	}
   }
   else{
	include 'admin.php'; // If ?id= is not set it will now go to your news page
   }   
   // Include this script in your content area
   // Run ?id=pagename (without .php) to view a page
  ?>

Edited by zetsumei, 14 August 2006 - 09:48 PM.


#2 venomsnake

    Jedi In Training

  • Members
  • PipPip
  • 481 posts
  • Gender:Male

Posted 15 August 2006 - 12:37 AM

what is line 50? we could help you if we knew what was on line 50

#3 zetsumei

    Young Padawan

  • Publishing Betazoids
  • Pip
  • 269 posts
  • Gender:Male
  • Location:127.0.0.1

Posted 15 August 2006 - 06:10 AM

View Postzetsumei, on Aug 14 2006, 10:47 PM, said:

the error im getting is
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/concept/public_html/admin/index.php on line 50

heres my php code
<?php
Line 50:   $val = $_GET['id']; // Replace id with whatever you want to use, eg ?id=page
   $val .= '.php'; // Makes the filename complete so if you called ?id=index, it would be index.php it has to look for
   $dirty = array('..');
   $clean = array('');
   $val = str_replace($dirty, $clean, $val); // Prevent people from viewing root files like your password (should work i just quikly added it without testing)
   
   if(isset($_GET['id'])){ // Replace id with whatever you want to use, eg ?id=page
	if(file_exists($val)){ // This checks if the file you are trying to call exists
	include '$val';
	}
	else{
	 include '404.php'; // If the file doesnt exists it calls your 404 error page
	}
   }
   else{
	include 'admin.php'; // If ?id= is not set it will now go to your news page
   }   
   // Include this script in your content area
   // Run ?id=pagename (without .php) to view a page
  ?>

sorry bout that...line 50 is marked now...

Edited by zetsumei, 15 August 2006 - 06:12 AM.


#4 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 15 August 2006 - 08:56 AM

You'll have to give us a few lines before that, because the error occurs from line 49 most probably. I can't remember what T_ENCAPSED_AND_WHITESPACE means, but you're most probably forgetting a semicolon or something.

Oh, and this line:
include '$val';

Should be changed to:
include $val;
Or
include($val);

Single quotes will parse it literally, so it would attempt to include '$val', which obviously isn't a filename. :)

#5 zetsumei

    Young Padawan

  • Publishing Betazoids
  • Pip
  • 269 posts
  • Gender:Male
  • Location:127.0.0.1

Posted 15 August 2006 - 01:26 PM

heres the php code thats above all the html...
<?php
include("dbconnect.php");
session_start();

// connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
mysql_select_db($dbname) or die('Cannot select database');

?>
<?
if (isset($_SESSION['s_username'])) {
echo "

the html is in that echo statement and then heres the other php thats for the navigation
<?php
 LINE 50  $val = $_GET['id']; // Replace id with whatever you want to use, eg ?id=page
   $val .= '.php'; // Makes the filename complete so if you called ?id=index, it would be index.php it has to look for
   $dirty = array('..');
   $clean = array('');
   $val = str_replace($dirty, $clean, $val); // Prevent people from viewing root files like your password (should work i just quikly added it without testing)
   
   if(isset($_GET['id'])){ // Replace id with whatever you want to use, eg ?id=page
	if(file_exists($val)){ // This checks if the file you are trying to call exists
	include $val;
	}
	else{
	 include '404.php'; // If the file doesnt exists it calls your 404 error page
	}
   }
   else{
	include 'admin.php'; // If ?id= is not set it will now go to your news page
   }   
   // Include this script in your content area
   // Run ?id=pagename (without .php) to view a page
  ?>


#6 zetsumei

    Young Padawan

  • Publishing Betazoids
  • Pip
  • 269 posts
  • Gender:Male
  • Location:127.0.0.1

Posted 15 August 2006 - 01:48 PM

SOLVED!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users