I am having a problem updating a record on a mysql database.
This works fine as long as there are no special characters.
B4X:
Sub btnUpdate_Click
data="op=updatemember" & _
"&id=" & memberid & _
"&firstname=" & editfirstname.Text & _
"&lastname=" & editlastname.Text & _
"&company=" & editCompany.text
Log (data)
getdata("updatemember",data)
End Sub
Sub getdata(jobname As String,jobdata As String)
job1.Initialize(jobname, Me)
job1.Download("http://www.whatever.com/getdata.php?" &jobdata)
End Sub
It quit updating when I urlencode it like this
B4X:
Sub btnUpdate_Click
data="op=updatemember" & _
"&id=" & memberid & _
"&firstname=" & editfirstname.Text & _
"&lastname=" & editlastname.Text & _
"&company=" & editCompany.text
Log (data)
Dim su As StringUtils
data = su.EncodeUrl(data, "UTF8")
getdata("updatemember",data)
End Sub
Sub getdata(jobname As String,jobdata As String)
job1.Initialize(jobname, Me)
job1.Download("http://www.whatever.com/getdata.php?" &jobdata)
End Sub
I thought that download2 would work better maybe but it doesn't update either.
B4X:
Sub btnUpdate_Click
updatedata("updatemember","op=updatemember")
End Sub
Sub updatedata(jobname As String,jobdata As String)
job2.Initialize(jobname, Me)
job2.Download2("http://www.whatever.com/getdata.php?" &jobdata,Array As String("id", memberid,"firstname",editfirstname.text,"lastname",editlastname.Text,"company",editCompany.text))
End Sub
You must url encode the parameters. If you want to use Job.Download2 then you need to move all the parameters to the array and also remove the question mark from the link.