Android Question how to create b4a trivia submitting the score and name of a user to php mysql database? could anyone help me badly needed thanks in advance.

PinayFlicks69

New Member
how to create b4a trivia submitting the score and name of a user to php mysql database? could anyone help me badly needed thanks in advance. BTW guys im a student :)
 

drgottjr

Expert
Licensed User
Longtime User
use the Okhttp and Okhttputils2 libraries to
post a string to your php server which will
accept the data and update your db. php
server will send some kind of acknowledgment
back to b4a to indicate how the update went.
presumably you know how to handle the
php end. it has nothing to do with b4a, although
b4a or any other http client needs to know what
kind of acknowledgement to expect (eg, "OK", "No
Such Name", "Record Updated", "Could Not
Update Record", etc, etc)

as for b4a, select the abovementioned libraries
from the libraries tab in the ide and code like this
(as an example):

B4X:
dim job as httpjob
job.initialize("",me)
dim stringforpost as string = "name=putin&score=0"
job.poststring("https://foo.bar/phpupdate", stringforpost)
job.getrequest.setContentType("application/x-www-form-urlencoded")
wait for (job) jobdone(job as httpjob)
if job.success then
   log(job.getstring)
else
   log(job.errormessage)
endif
job.release

php server determines what it will accept (in terms of data) and
how it will respond. b4a http client is coded accordingly (example
above may not apply...). example above is typical of a simple exchange
presuming the programmer controls both ends. if the programmer only
controls the b4a end, then she needs to ask the php server's administrator
exactly what data are required to update a database (perhaps a password?)
and exactly what kind of response is sent.

this is the easiest scenario. it is not the only scenario. not all servers
are http servers. i have no way of knowing how your php server
functions.
 
Upvote 0
Top