tags:

views:

43

answers:

1

So I have just rebuilt my server, just on local network. Stick my site back on it, try to run the code, and I get a anice T_STRING error. This is all very strange, as I have not changed the code :S

<?php
$window_ID = -1;
if(isset($_POST["window_ID"]) AND $_POST["window_ID"] != null){
  $window_ID = trim($_POST["window_ID"]);
}
?>

This is the start of the file, apter this rather loverly snipit of PHP the rest is just XMl, yet on line 6 appertnlty there is an unexpected T_STRING, which is strange considering all that is on that line is the ?>, then the XML starts up...

Any one got any ideas what has gone wrong here? Any chance it ould be magic quotes? I had turned it of before, but I want to now update my code to check for the magic quotes and avoid its stupid actions.

+4  A: 

You might have short_open_tags enabled. The opening tag for xml <? is probably invoking the PHP interpreter and subsequently throwing this error when it sees the XML content.

Mike B
I thought short tags had to be enabled? By default that silly feature will not be on. I am sure more people use XML, thus `<?xml` then are too lazy to add in `php`
thecoshman
Check `phpinfo()` and see.
Mike B
I Googled the old php manual and it says it is on by default, and suggest you can use echo '<?xml ... ?>'. I hate the way so many 'features' of php actually twat you over!
thecoshman
It's default on in PHP 5. Note you probably don't actually need an `<?xml` declaration in your file anyway, unless you are using XML 1.1 or a non-UTF-8 encoding. If you do really need to have an XML Declaration and still be short-tag-compatible, `<?php echo '<?xml ...?'.'>'; ?>`.
bobince
Why would I not need it in the file? I am loading the XML content so that my JavaScript can simply load the content into a tag, and then scan through it. Being XML means I already have the sir-weet node structure and all the associated access functions of the bat... except selecting by class... but that's another issue entirely!
thecoshman