MyBB Community Forums

Full Version: Parse Error, but can't find problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This is the error I'm getting.
Parse error: syntax error, unexpected T_STRING in /home/ansem/public_html/fail.php on line 1
This is what I have in the file
<?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" lang="en" xml:lang="en">
<head>
<title>Server Error - Church of Gaming</title>
</head>
<body>
<p><a href="./">Church of Gaming</a> is currently down because of a server-side issue: "<?php echo htmlspecialchars(@$_GET['error'], ENT_COMPAT, 'UTF-8'); ?>".</p>
<p>The javascript web client below connects to our main IRC channel at <a href="#">irc://#/a>.<br/>
You can use it to make us aware of the problem, keep track of the current status, and chat with other players.</p>
<iframe src="#" width="647" height="400"></iframe>
</body>
</html>

I don't get how the error can be on line 1 or how to fix it.
I do have this in my index though, because I'm using .xml files on some places

<?php
	// redirect errors to our own logfile
	error_reporting(-1); // everything
	ini_set("display_errors", "Off");
	ini_set("error_log", "logs/churchofgaming-error-".strftime('%Y%m%d').".log");

	// enable xhtml+xml mode if the client supports it
	if ( stristr(@$_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") )
		header("Content-type: application/xhtml+xml");
	else
		header("Content-type: text/html");

	require_once("main.php");
?>
Well, I would guess its that:
<?xml version="1.0" encoding="UTF-8"?>

You need to:
a) Disable "short_open_tag" in the php.ini
b) Output this instead:
<?php echo("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); ?> 

That way the PHP parser will ignore it Smile
(2012-02-08, 07:13 PM)Tom K. Wrote: [ -> ]Well, I would guess its that:
<?xml version="1.0" encoding="UTF-8"?>

You need to:
a) Disable "short_open_tag" in the php.ini
b) Output this instead:
<?php echo("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); ?> 

That way the PHP parser will ignore it Smile

Not really in the mood to change ever file Toungue
What would be the line I'd need to put into the php.ini ?
This:
; Allow the <? tag.  Otherwise, only <?php and <script> tags are recognized.
; NOTE: Using short tags should be avoided when developing applications or
; libraries that are meant for redistribution, or deployment on PHP
; servers which are not under your control, because short tags may not
; be supported on the target server. For portable, redistributable code,
; be sure not to use short tags.
short_open_tag = On
Should be this:
; Allow the <? tag.  Otherwise, only <?php and <script> tags are recognized.
; NOTE: Using short tags should be avoided when developing applications or
; libraries that are meant for redistribution, or deployment on PHP
; servers which are not under your control, because short tags may not
; be supported on the target server. For portable, redistributable code,
; be sure not to use short tags.
short_open_tag = Off

Smile Basically, PHP is accepting <? and ?> as valid php tags, so is confused when that XML statement doesnt contain any semi-colons Smile
I wonder why they don't specifically test for and ignore <?xml ... ?> since it's a really dang common use of <? ?> that's not for PHP...
(2012-02-08, 08:14 PM)Firestryke31 Wrote: [ -> ]I wonder why they don't specifically test for and ignore <?xml ... ?> since it's a really dang common use of <? ?> that's not for PHP...

I have always wondered the same. Although TBH i thought they only accepted <? followed by a "space", not any other character. For example, I didnt think they would accept <?blah but evidently they do Confused
how important is it actually to have the line: <?xml version="1.0" encoding="UTF-8"?>
If I remove it, will it mess up the script ?
You are better off just diabling short php tags Smile As long as you use <?php to open your php code it's fine. Really, no code should ever be developed using short tags if it is to be released to the public. As many servers have them disabled.