• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 510
  • Last Modified:

php error in javascript ( PHP Parse error: syntax error, unexpected T_STRING )

I have copied the exact source code of this site because I would like to use this example:
http://www.geocodezip.com/v3_GoogleEx_directions-draggable2Xml.html

I can't find out why I'm getting this error within this javascript:

PHP Parse error:  syntax error, unexpected T_STRING in /var/www/html/domain/test4.html on line 202

Why does my server try to execute javascript as php in this case starting at line 202? There is no

<?php ...

?>

in this javascript.  Really strange ..



0
seopti
Asked:
seopti
  • 2
2 Solutions
 
seoptiAuthor Commented:
I found out it is because of this line in .htaccess:

Addhandler application/x-httpd-php .html .php

Seems I have to change it.
0
 
Ray PaseurCommented:
Interesting... That line in .htaccess says, Take all URLs with file names that end in .html or .php and feed them to the PHP parser.  I use that quite often when I have a colleague developer writing in Dreamweaver.  There may be something else wrong, however.  You might need to turn off the "short open tag" settings if you have any XML in the mix.
0
 
seoptiAuthor Commented:
Thanks but when using:
php_flag short_open_tag off


all my other php scripts will not be parsed.
0
 
hieloCommented:
I agree with Ray. This line:

document.getElementById("polyline").value="<?xml version='1.0' encoding='UTF-8'?>\n<markers>\n";

is "seen/interpreted" as:
document.getElementById("polyline").value="<?phpxml version='1.0' encoding='UTF-8'?>\n<markers>\n";

because you do have short_tag_open set to true. So it will attempt to execute xml..., but that is NOT valid php syntax. If you cannot set it off, what you need to do is enclose the <?xml...?> in single quotes :

document.getElementById("polyline").value="<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>\n<markers>\n";

0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now