Jump to content

Archived

This topic is now archived and is closed to further replies.

kvegas

[SOLVED] Passing PHP Variables to a Java Applet

Recommended Posts

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.)

Share this post


Link to post
Share on other sites

The variable value is assgined wrong

it should be in quotation marks

like so

<?php
$playrom = "http://maverik247.com/vnes/roms/dkong.nes";
?>

Share this post


Link to post
Share on other sites

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>

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.  :-[

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.