kvegas Posted November 25, 2008 Share Posted November 25, 2008 I'm using this code to attempt to assign a variable through php, then retrieve the variable within a java applet. The problem is... well it doesn't seem to work. The applet loads but it doesn't load the file. Here's my code... <?php $playrom=http://maverik247.com/vnes/roms/dkong.nes; ?> <applet name="vNES" code="vNES.class" archive="http://maverik247.com/vnes/vnes203.jar" width="512" height="480"> <param name="sound" value="on" /> <param name="timeemulation" value="on"/ > <param name="fps" value="off" /> <param name="stereo" value="off" /> <param name="rom" value="<?php echo $playrom;?>" /> <param name="showsoundbuffer" value="off" /> <param name="scale" value="on" /> <param name="scanlines" value="off" /> <param name="nicesound" value="on" /> <param name="romsize" value="45056" /> </applet> The following code DOES work, but as you can see, it doesn't allow anything but the predefined URL... <param name="rom" value="http://maverik247.com/vnes/roms/dkong.nes" /> Can anyone help please? Eventually, $playrom will need to get it's data from a URL such as "http://maverik247.com/vnes/roms/play.php&game=dkong.nes" but for right now, I'm just trying to learn how to pass the variable this way. (I figure step by step is the way to go so I don't get confused when things don't work.) Quote Link to comment https://forums.phpfreaks.com/topic/134280-solved-passing-php-variables-to-a-java-applet/ Share on other sites More sharing options...
DeanWhitehouse Posted November 25, 2008 Share Posted November 25, 2008 The variable value is assgined wrong it should be in quotation marks like so <?php $playrom = "http://maverik247.com/vnes/roms/dkong.nes"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/134280-solved-passing-php-variables-to-a-java-applet/#findComment-699064 Share on other sites More sharing options...
kvegas Posted November 25, 2008 Author Share Posted November 25, 2008 The variable value is assgined wrong it should be in quotation marks like so <?php $playrom = "http://maverik247.com/vnes/roms/dkong.nes"; ?> Made the change, still not working... here's the current code: <?php $playrom = "http://maverik247.com/vnes/roms/dkong.nes"; ?> <applet name="vNES" code="vNES.class" archive="http://maverik247.com/vnes/vnes203.jar" width="512" height="480"> <param name="sound" value="on" /> <param name="timeemulation" value="on"/ > <param name="fps" value="off" /> <param name="stereo" value="off" /> <param name="rom" value=value="<?php echo $playrom;?>" /> <param name="showsoundbuffer" value="off" /> <param name="scale" value="on" /> <param name="scanlines" value="off" /> <param name="nicesound" value="on" /> <param name="romsize" value="45056" /> </applet> Quote Link to comment https://forums.phpfreaks.com/topic/134280-solved-passing-php-variables-to-a-java-applet/#findComment-699071 Share on other sites More sharing options...
DeanWhitehouse Posted November 25, 2008 Share Posted November 25, 2008 You have value written twice <param name="rom" value=value="<?php echo $playrom;?>" /> should be <param name="rom" value="<?php echo $playrom;?>" /> Are you even looking at your code? Quote Link to comment https://forums.phpfreaks.com/topic/134280-solved-passing-php-variables-to-a-java-applet/#findComment-699072 Share on other sites More sharing options...
kvegas Posted November 26, 2008 Author Share Posted November 26, 2008 Oh gosh, sorry. I didn't realize I'd posted the code that way. It's a mistake I've already corrected, and it wasn't the problem sadly. Quote Link to comment https://forums.phpfreaks.com/topic/134280-solved-passing-php-variables-to-a-java-applet/#findComment-699082 Share on other sites More sharing options...
DeanWhitehouse Posted November 26, 2008 Share Posted November 26, 2008 Although the PHP is working fine now, so i assume it must be the JAVA applet. Quote Link to comment https://forums.phpfreaks.com/topic/134280-solved-passing-php-variables-to-a-java-applet/#findComment-699083 Share on other sites More sharing options...
kvegas Posted November 26, 2008 Author Share Posted November 26, 2008 Is there possibly another way to achieve the results I'm after? Quote Link to comment https://forums.phpfreaks.com/topic/134280-solved-passing-php-variables-to-a-java-applet/#findComment-699084 Share on other sites More sharing options...
Maq Posted November 26, 2008 Share Posted November 26, 2008 I think this is because you're trying to assign a server side variable to a client side language (applet)... But I could be very wrong. Quote Link to comment https://forums.phpfreaks.com/topic/134280-solved-passing-php-variables-to-a-java-applet/#findComment-699116 Share on other sites More sharing options...
DeanWhitehouse Posted November 26, 2008 Share Posted November 26, 2008 That shouldn't effect it as the PHP is producing the HTML. It might just be the applet, but as the PHP is solved. Please press the solved link at the bottom left. Quote Link to comment https://forums.phpfreaks.com/topic/134280-solved-passing-php-variables-to-a-java-applet/#findComment-699118 Share on other sites More sharing options...
Philip Posted November 26, 2008 Share Posted November 26, 2008 From the sun boards, seems they got it solved - however it looks to be the same thing you are doing (on the PHP side anyways).... http://forums.sun.com/thread.jspa?threadID=780050 The best way to do this is to use PARAM in the PHP/HTML where you call the Applet from, and GetParameter from inside the applet. Suppose you have to pass in a user password from the PHP/HTML code, into an applet. Perhaps you have to connect to the same database from inside the applet, that you are connected to from inside the PHP - where you collected the user's password. In this case, youll have to pass the password from the php code into the applet, if you want to connect to the database from inside the applet. Where you call the applet from the PHP / HTML code, use PARAM. Suppose the password is stored in a php variable, 'db_pwd' : ?> // end php and use HTML // load the applet <applet code=TheApplet.class width=1000 height=1000> // use php code for this one 'echo' call, and send the password value <param name=password value=<?php echo($db_pwd);?>> // done loading applet </applet> // back to php code <?php From inside the java class applet get the password: //TheApplet.java String password = getParameter("password"); Hope this helps. Thomas Shavel Quote Link to comment https://forums.phpfreaks.com/topic/134280-solved-passing-php-variables-to-a-java-applet/#findComment-699160 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.