How do you pass a variable from PHP to JAVA?
i triedvar x= <?php echo $variable; ?>it doesn't work
You are going to have a problem with this, obviously, given that PHP and JAVA are running on two different computers. Remeber that PHP is running on the web server and by the time a web page starts loading on the local client (or web site visitor) machine PHP is already done and no longer executing. Then once the page is loaded for the visitor any Java script or Java applet can run. Thus the best method for the two to share data seems to be the web page and/or the HTML created by PHP. Perhaps trying to have a form element (hidden if you wish) with a value written in by the PHP and then once the Java starts to execute have Java read that value into a variable. There may be other ways as well but this is off the top my head and sems to be a fairly simple solution.
Hmm... what i want to pass is a number form database, lets say i got this number and its $x, how do i pass it?
The code you wrote should work, I'm sure something else is the real problem
Do "View | Page Source" in your browser, and see what actually arrived in the web page. If $variable had the value 5 in the database accessed by the PHP script, the page source should have var x=5 when it arrives in your browser.
If it does not, then you can localize the cause. For example, if the <?php string is still there, you aren't executing the PHP. If the 5 is there but the browser-side result isn't what you want, then you may be generating a web page with a syntax error, such as a missing semicolon.
If necessary, add some print statements in the PHP that generate plain HTML, so you can debug what is actually happening, as opposed to what you intended.
Computers have the bad habit of doing what you tell them to do, not what you want them to do!
|VIEW DESKTOP VERSION||REGISTER||GET FREE HOSTING|