Page 1 of 1

Writing Java with PHP

Posted: Tue Sep 08, 2009 5:11 pm
by freewill09
I want to feed a php variable into a javascript code.

<?php
echo "<script type=\"text/javascript'>;\n";
echo "var so = new SWFObject(\"../../../../playerMultipleMenuPackage/;');\n";
echo $_GET['$products_id'];
echo "\"/playerMultipleList.swf\", \"mymovie\", \"295\", "\200\", \"7\", \"#FFFFFF\");\n";
echo "so.addVariable(\"autoPlay\",\"no\");\n"
echo "so.addVariable(\"playlistPath\",\"playlist.xml\");\n";
echo "so.write(\"flashPlayer\");\n";
echo "</script>;\n";
?>

What is incorrect

Re: Writing Java with PHP

Posted: Tue Sep 08, 2009 5:17 pm
by jayshields
For a start there are lots of mismatched quote marks.

Re: Writing Java with PHP

Posted: Tue Sep 08, 2009 9:10 pm
by freewill09
I want the php to write this code:

<script type="text/javascript">
var so = new SWFObject("../../../../playerMultipleMenuPackage/php variable/playerMultipleList.swf", "mymovie", "295", "200", "7", "#FFFFFF");
so.addVariable("autoPlay","no")
so.addVariable("playlistPath","../../../../playerMultipleMenuPackage/playlist.xml")
so.write("flashPlayer");
</script>

Re: Writing Java with PHP

Posted: Tue Sep 08, 2009 9:48 pm
by ell0bo
use a heredoc to clean that mess up my friend...
$js = <<<JS
<script type="text/javascript">
var so = new SWFObject("../../../../playerMultipleMenuPackage/php variable/playerMultipleList.swf", "mymovie", "295", "200", "7", "#FFFFFF");
so.addVariable("autoPlay","no")
so.addVariable("playlistPath","../../../../playerMultipleMenuPackage/playlist.xml")
so.write("flashPlayer");
</script>
JS;

echo $js;

Anything you need dynamic just replace with a variable...

Re: Writing Java with PHP

Posted: Tue Sep 08, 2009 10:39 pm
by freewill09
Thanks jayshields and ell0bo

did exactly what I needed to do