Solved

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

Posted on 2011-03-11
4
501 Views
Last Modified: 2012-05-11
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
Comment
Question by:seopti
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Author Comment

by:seopti
ID: 35110881
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
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 250 total points
ID: 35110965
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
 

Author Comment

by:seopti
ID: 35111053
Thanks but when using:
php_flag short_open_tag off


all my other php scripts will not be parsed.
0
 
LVL 82

Assisted Solution

by:hielo
hielo earned 250 total points
ID: 35111210
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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question