[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2011-03-11
4
Medium Priority
?
506 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 111

Accepted Solution

by:
Ray Paseur earned 1000 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 1000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

656 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