Hello every one, i trying to convert image to byte then to string, everything okay and done save.
But when i read from Mysql database i get error.
This is my error.
But when i read from Mysql database i get error.
B4X:
ExecuteRemoteQuery("SELECT * FROM tblTest", GetImage)
B4X:
Sub ExecuteRemoteQuery(Query As String, JobName As String)
Dim job As HttpJob
job.Initialize(JobName, Me)
job.PostString("http://www.mydomain.com/myphp.php", Query)
End Sub
B4X:
Sub JobDone(Job As HttpJob)
Dim MySQL_Data As List
Dim M As Map
If Job.Success Then
Dim res As String
res = Job.GetString
Log("Response from server: " & res)
Dim parser As JSONParser
parser.Initialize(res)
Select Job.JobName
Case GetImage
MySQL_Data = parser.NextArray 'This line get error
If MySQL_Data.Size > 0 Then
For I = 0 To MySQL_Data.Size -1
M = MySQL_Data.Get(I)
Dim s As String = M.Get("Image")
Dim b () As Byte = s.GetBytes("UTF8")
BytesToFile(File.DirInternal, "Download.png", b)
IV.Bitmap = LoadBitmap(File.DirInternal, "Download.png")
Next
End If
End Select
Else
Log(Job.ErrorMessage)
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub
This is my error.
B4X:
Response from server: <img src="data:image/jpeg;base64,"/>
main_jobdone (B4A line: 70)
MySQL_Data = parser.NextArray
java.lang.RuntimeException: JSON Array expected.
at anywheresoftware.b4a.objects.collections.JSONParser.NextArray(JSONParser.java:62)
at b4a.example.main._jobdone(main.java:550)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at anywheresoftware.b4a.keywords.Common$11.run(Common.java:1144)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)