Android Question POST String and variable to PHP

Peter Lewis

Well-Known Member
Licensed User
Longtime User
HI All

I have managed to post values to the php file but cannot manage to change the values for variables.

I tried this method but it only posts a blank

Any Ideas ?

Thank you

Code: Copy
    Label1.Text = mResult
    job2.Initialize("Job2", Me)
    job2.PostString("http://www.himel.co.za/sen_post.php","Barc="& mResult &"Location=PMB&User=Peter")
 
I tried this method but it only posts a blank
What did you expect? The Label will hold the content of the variable "mResult". I guess it is an empty string.`That´s why you get an empty content...

Poststring does not set any value...

What exactly are you trying to do?

Do you want the answer from the php to be in your label?

If yes then you should get the result inside the JobDone sub....

Code: Copy
Sub JobDone(Job As HttpJob)
    ProgressDialogHide
    Log("JobName: "&Job.JobName)
    If Job.Success = False Then
        Log(Job.ErrorMessage)
        ToastMessageShow("Error: " & Job.ErrorMessage, True)
        Label1.Text = Job.ErrorMessage
    else If Job.Success Then
        If Job.JobName = "Job2" Then
            Dim res As String
            res = Job.GetString
            Log(res)
            Label1.Text = res
        End If
    End If
    Job.Release
End Sub
 
Upvote 0
What did you expect? The Label will hold the content of the variable "mResult". I guess it is an empty string.`That´s why you get an empty content...

Poststring does not set any value...

What exactly are you trying to do?

Do you want the answer from the php to be in your label?

If yes then you should get the result inside the JobDone sub....

Code: Copy
label1.text = Job.GetString()

Thank you for your help.

I am trying to post the value of a variable to a sql Database
The variable is mResult

If I use this code

Code: Copy
mResult = barCode
    job2.Initialize("Job2", Me)
    job2.PostString("http://www.himel.co.za/sen_post.php","Barc="&mResult&"Location=PMB&User=Peter")

Then I am getting the result as attached under result.jpg and somehow the Location=PMB has combined with mResult in the database. There is something I am missing , either too many & or I need to add a ' or "

Thank you
 

Attachments

  • result.jpg
    result.jpg
    9.9 KB · Views: 548
Upvote 0
What about something like this ?

Code: Copy
job2.PostString("http://www.himel.co.za/sen_post.php","Barc="&mResult&"&Location=PMB&User=Peter")
 
Upvote 0
Code: Copy
    Dim mResult As String = "blablabla"
    Dim job2 As HttpJob
    job2.Initialize("Job2", Me)
    'job2.PostString("http://www.himel.co.za/sen_post.php","Barc="&mResult&"Location=PMB&User=Peter")
    job2.PostMultipart("http://www.himel.co.za/sen_post.php",CreateMap("Barc":mResult,"Location":"PMB","User":"Peter"),Null)
 
Upvote 0
Code: Copy
    Dim mResult As String = "blablabla"
    Dim job2 As HttpJob
    job2.Initialize("Job2", Me)
    'job2.PostString("http://www.himel.co.za/sen_post.php","Barc="&mResult&"Location=PMB&User=Peter")
    job2.PostMultipart("http://www.himel.co.za/sen_post.php",CreateMap("Barc":mResult,"Location":"PMB","User":"Peter"),Null)

Thank you

That is a lot cleaner
 
Upvote 0
Back
Top