Forum Moderators: coopster
Parse error: parse error, unexpected T_STRING in /bla/bla/bla/bla.com/bla_html/spider/admin/messages.php on line 116
The line surrounding and the error line are
114
function printQuitReport($command_line) {
115
if ($command_line == 0)
116
print"<script language="JavaScript"> var LSPT=""; LSPT += "?durl=" + escape(document.URL); LSPT += "&hostname=" + location.hostname; LSPT += "&url=" + location.pathname; LSPT += "&query=" + escape(location.search) + escape(location.hash); LSPT += "&referrer=" + escape(document.referrer); LSPT += "&browser=" + escape(navigator.appName); LSPT += "&version=" + escape(navigator.appVersion); LSPT += "&os=" + escape(navigator.platform); LSPT += "&xdomain=army.com"; LSPT += "&custid=army"; </script> <script Language="Javascript"> document.write('<img src=http://'+'content.example.com/images/pixel.gif'+LSPT+' height="1" width="1">'); </script> <noscript><img src="http://content.example.com/images/pixel?version=nonjava" height="1" width="1"> </noscript></body></html>";
117
flush();
118
}
I know that is a monstrously long line of code but I did not write it I just have to fix it. The </body></html> tags are opened earlier in the program. I appreciate any suggestions anyone can give me.
Thanks,
Drunk
[edited by: jatar_k at 8:14 pm (utc) on Feb. 16, 2007]
[edit reason] examplified [/edit]
it is just a matter of mismatched quotes
looking at the first bit
print"<script language="JavaScript">...
the string to be printed needs to be enclosed in quotes, either single or double
your couble quotes start right after the print but then there is a matching set right after language= therefore all you feed to your print is
print"<script language="
and the next bit looks like a string to the parser. You need to escape double quotes inside your string, like so
print"<script language=\"JavaScript\">...
and carry this on for all double quotes within that massive string
reference
[php.net...]
All your double quotes will need to be escaped... or you could use heredoc [php.net] syntax to avoid that:
print <<<___EOF
<script language="JavaScript"> var LSPT=""; LSPT += "?durl=" + escape(document.URL); LSPT += "&hostname=" + location.hostname; LSPT += "&url=" + location.pathname; LSPT += "&query=" + escape(location.search) + escape(location.hash); LSPT += "&referrer=" + escape(document.referrer); LSPT += "&browser=" + escape(navigator.appName); LSPT += "&version=" + escape(navigator.appVersion); LSPT += "&os=" + escape(navigator.platform); LSPT += "&xdomain=army.com"; LSPT += "&custid=army"; </script> <script Language="Javascript"> document.write('<img src=http://'+'content.example.com/images/pixel.gif'+LSPT+' height="1" width="1">'); </script> <noscript><img src="http://content.example.com/images/pixel?version=nonjava" height="1" width="1"> </noscript></body></html>
___EOF;
Added: And I type slow... ;)
Added: Watch out if you copy and paste, the WebmasterWorld software adds a space at the end of the <<<___EOF line that needs to be removed.
[edited by: whoisgregg at 8:26 pm (utc) on Feb. 16, 2007]
print "<script language=\"JavaScript\"> var LSPT=\"\"; LSPT += \"?durl=\" + escape(document.URL); LSPT += \"&hostname=\" + location.hostname; LSPT += \"&url=\" + location.pathname; LSPT += \"&query=\" + escape(location.search) + escape(location.hash); LSPT += \"&referrer=\" + escape(document.referrer); LSPT += \"&browser=\" + escape(navigator.appName); LSPT += \"&version=\" + escape(navigator.appVersion); LSPT += \"&os=\" + escape(navigator.platform); LSPT += \"&xdomain=army.com\"; LSPT += \"&custid=army\"; </script> <script Language=\"Javascript\"> document.write('<img src=http://'+'content.example.com/images/pixel.gif'+LSPT+' height=\"1\" width=\"1\">'); </script> <noscript><img src=\"http://content.example.com/images/pixel?version=nonjava\" height=\"1\" width=\"1\"> </noscript></body></html>";
parsed for me though I don't know if it does what you want
We have a winner. Thank you for your suggestions. Jatar_k The code that you escaped worked wonderfully. whoisgregg, thank you for the advice, I had seen something similar in another post but had not relized that it would be required throughout the whole line. I had thought that the error was coming towards the end of that monster. My site is now re indexing so that I can search it and find the newer more relevant articles. This is the most awesomest forum ever. You guys rock.
It's five O'clock somewhere,
Drunk