Jump to content

[SOLVED] Passing PHP Variables to a Java Applet


kvegas

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

Link to comment
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>

Link to comment
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.