B4J Question Read server variables through HTTP/PHP/MySQL

ThRuST

Well-Known Member
Licensed User
Longtime User
My domain at webhost www.one.com doesn't allow direct connections from B4J SQL code so I will have to either change webhotel (prefferrably not) or read/write variables from my B4J application through HTTP and make PHP scripts manipulate the contents of the MySQL database. I want to be able to read and write data both from B4J and then the same with B4A and B4i. Any examples how to achieve this? okhttp2 library?, but how?
 

ThRuST

Well-Known Member
Licensed User
Longtime User
Once I passed variables through webview to the server (from B4A). A PHP script took care of the variables by using $_GET.
How can I the same way read a variable from PHP, and have the variables passed back to the client as alternative ways?
I think this could be done by using the HTTP library, and add Arrays as values. Can this be used for both GET, POST and Return value as well?

Example

http://www.domain.com/?firstname=Erel&company=Anywhere software
PHP will read variables with GET.
But how to send back to the client in similar way? From SERVER -> to CLIENT
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Thanks KMatle, to be specific which library do you refer to and recommend, since there's many ways to fry a chicken :).
What I need is a solution that works for B4A, B4i and also from B4J. Advice is appreciated, Cheers Roger
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Sorry my misstake, I did not pay attention to the links under your name. httputils2 looks interresting. Might be what I'm looking for.
I was looking for a simple and convenient way to achieve this, and I think your solution looks easier because I'm not a fan of Json.
Hopefully httputils2 can do the same work, anyway thanks for clearing this out.
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Great, but I allready know PHP even though that site is a good reference. I will study the okhttp and okhttputils.. those are new to me.
Recently I covered SQLite with source code example, so this seems like a natural step so I will gladly be an apprentice of your teachings :D
Thank you lord KMatle :)
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Hey KMatle I need your help :) I've covered your tutorials on in this case jokhttputils2 and managed to read a record from mySQL database on my server, which is great but I wonder how can I associate each cell that is read with a variable (in this case B4J but it shouldn't matter I think), instead of using multiply reading just to store each cell into a variable so that I can use the database info from memory. How do I handle this in jobdone or is there another way? i.e. how to store Firstname and Lastname data from the database into string variables from jobdone. Thanks
 
Upvote 0
Top