1,105,391 Community Members

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

Member Avatar
MikeFL
Newbie Poster
4 posts since Feb 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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>
Member Avatar
pritaeas
mod_pritaeas
11,315 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,835 [?]
Skill Endorsements: 156 [?]
Moderator
Featured
Sponsor
 
0
 

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

Member Avatar
MikeFL
Newbie Poster
4 posts since Feb 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
vaultdweller123
Posting Pro
577 posts since Sep 2009
Reputation Points: 32 [?]
Q&As Helped to Solve: 84 [?]
Skill Endorsements: 2 [?]
 
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" ?>'; ?>
Member Avatar
MikeFL
Newbie Poster
4 posts since Feb 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
vaultdweller123
Posting Pro
577 posts since Sep 2009
Reputation Points: 32 [?]
Q&As Helped to Solve: 84 [?]
Skill Endorsements: 2 [?]
 
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

Member Avatar
MikeFL
Newbie Poster
4 posts since Feb 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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: