86Stang Posted January 11, 2010 Share Posted January 11, 2010 I'm trying to use a 3rd party app for commenting inside a PHP variable. The app code I'm trying to include: <script> var idcomments_acct = '12345'; var idcomments_post_id; var idcomments_post_url; </script> <script type="text/javascript" src="http://www.website.com/script.js"></script> I'm trying to put it into a variable like: $output .= "<script>"; $output .= "var idcomments_acct = '12345'\;"; $output .= "var idcomments_post_id\;"; $output .= "var idcomments_post_url\;"; $output .= "</script>"; $output .= "<script type=\"text/javascript\" src=\"http://www.website.com/script.js\"></script>"; and finally render it in the HTML by using: <?php echo $output; ?> I'm not getting any errors but nothing is showing up either. Is this just basically not allowed, did I forget to escape something, is my approach all wrong, what? Quote Link to comment https://forums.phpfreaks.com/topic/188103-putting-some-java-inside-php/ Share on other sites More sharing options...
mikesta707 Posted January 11, 2010 Share Posted January 11, 2010 first off, thats Javascript, not Java. Secondly, that looks fine, but that javascript doesn't look like it will do anything (unless the external script does something) What do you expect it to do, and what is it actually doing. Have you looked in the error console to make sure there is no errors Have you tried just putting the script directly in the HTML? I don't see why you are putting it in PHP in the first place. on a second glance, you don't need to escape semi colons, so try removing the backslashes that are infront of the semi colons. That will cause a javascript syntax error Quote Link to comment https://forums.phpfreaks.com/topic/188103-putting-some-java-inside-php/#findComment-993071 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.