Pass a JAVA var to use in php file

Hello,

I have a variable (var) in java.

I need to use the variable in a PHP file to interact with MySQL database.

How do I pass the var to use it as php variable?

(it just a word like “car” that I am passing - should not be difficult)

Thanks.

PHP always runs first, it’s a preprocessor, after which the scripting on the page runs.

You will need to send the information either as a query string parameter, or as a POST to the PHP script.

You’ve posted in the JavaScript forum, @MatthewBOnline. Do you mean Java or JavaScript?

2 Likes

I am not sure whether I am/should be using JAVA, JAVASCRIPT or AJAX

It might be a good idea to describe your setup - browser, server, what files are being used on each. At the moment, any answer we gave you would be as good as any other, and quite likely all wrong anyway.

2 Likes

Assuming you mean JavaScript and not Java (what’s the difference), you would fire off an Ajax request from your web page to the server. The server would receive whatever values you pass it, run its query, then return a response. Back on your webpage, you can receive this response and use it to further interact with the DOM or whatever.

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.