1.11M Members

PHP Parse error: syntax error, unexpected T_STRING in /var/www/index.php on line 33

 
0
 

I'm still kinda new to php and have been getting this error:
PHP Parse error: syntax error, unexpected T_STRING in /var/www/index.php on line 33

It's all running on a LAMP server in a local VM. Been looking at it for the last 2 days and can't find what is wrong, everything looks right to me. Is the error referring to just the code below, or is it actually referring to one of the includes? I've included what I think is just the relevant php section, not the whole page. Any help you guys can provide a novice is greatly appreciated.

<?php 
	$g_content = "";

	include_once './php/filter.php'; // has to be first
	filter_redirect();
	//
	include_once './php/db.php';
	include_once './php/common.php';
	
	include_once './php/session.php';
	include_once './php/language.php';
	
	$build_number = "9.0b"; $build = file_get_contents('.build');
	
	define("PAGE_HOME",0);
	define("PAGE_PLANNER",1);
	define("PAGE_LOGIN",2);
	define("PAGE_LOGOUT",3);
	define("PAGE_SPELL",4);
	define("PAGE_ITEM",5);
	define("PAGE_SPELLS",6);
	define("PAGE_ITEMS",7);
	define("PAGE_TALENTS",8);
	define("PAGE_FORUM",9);
	define("PAGE_REGISTER",10);
	define("PAGE_DONATE",11);
	define("PAGE_RECOVER_PASSWORD",12);
	define("PAGE_BASE_STATS",13);
	define("PAGE_PLANNER_START",14);
	define("PAGE_USER",15);
	define("PAGE_CREDITS",16);
	define("PAGE_PROFILES",17);
?><?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 
0
 

Have you tried putting the xml tag in the first line of your file ? Perhaps short tags is enabled and causing this issue.

 
0
 

Have you tried putting the xml tag in the first line of your file ? Perhaps short tags is enabled and causing this issue.

I just tried that, pritaeas....

<?xml version="1.0" encoding="UTF-8"?>
<?php 
	$g_content = "";

	include_once './php/filter.php'; // has to be first
	filter_redirect();
	//
	include_once './php/db.php';
	include_once './php/common.php';
	
	include_once './php/session.php';
	include_once './php/language.php';
	
	$build_number = "9.0b"; $build = file_get_contents('.build');
	
	define("PAGE_HOME",0);
	define("PAGE_PLANNER",1);
	define("PAGE_LOGIN",2);
	define("PAGE_LOGOUT",3);
	define("PAGE_SPELL",4);
	define("PAGE_ITEM",5);
	define("PAGE_SPELLS",6);
	define("PAGE_ITEMS",7);
	define("PAGE_TALENTS",8);
	define("PAGE_FORUM",9);
	define("PAGE_REGISTER",10);
	define("PAGE_DONATE",11);
	define("PAGE_RECOVER_PASSWORD",12);
	define("PAGE_BASE_STATS",13);
	define("PAGE_PLANNER_START",14);
	define("PAGE_USER",15);
	define("PAGE_CREDITS",16);
	define("PAGE_PROFILES",17);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

So now, it points to line 1. Which tells me that it's something with that XML line with the encoding specified. Again, it looks right to me. Gotta do a little more research.

 
0
 

i think the xml DTD is conflicting with the php short tags, i think there are many solutions on this but try this quick fix

<?php echo '<?xml version="1.0" encoding="utf-8" ?>'; ?>
 
0
 

i think the xml DTD is conflicting with the php short tags, i think there are many solutions on this but try this quick fix

<?php echo '<?xml version="1.0" encoding="utf-8" ?>'; ?>

I was just looking at the php.ini file. I was reading somewhere that it's a good idea to turn off short tags, but i'm wondering if it will also cause the parsing of the php code to stop completely. Thoughts on this?

vaultdweller123: I'll try that now and see what happens.

 
0
 

you can disable short tags, if you do not always use this, disabling it will cause no harm. but like myself, i always use php shortags so id rather echo the xml DTD rather than turning it off so decide on what suits you

 
0
 

you can disable short tags, if you do not always use this, disabling it will cause no harm. but like myself, i always use php shortags so id rather echo the xml DTD rather than turning it off so decide on what suits you

echoing the xml DTD worked. Thanks for the assist!

Question Answered as of 2 Years Ago by vaultdweller123 and pritaeas
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: