Error Mysql 'cannot parse:.....as boolean'

Asmoro

Active Member
Licensed User
Longtime User
Hi all,

I recently starting to learn Mysql using Netchicken sample of Mysql ('sql-scores')

My testproject went well except the error I get 'cannot parse .....as boolean'.
Searching at the forum I didn't find the solution what I need.

So, if you know the answer, let's hear it.

Hopefully it will,

Tia,
Asmoro

Log error:

main_httpc_responsesuccess (java line: 351)
java.lang.RuntimeException: Cannot parse: Alfa RomeoItalieBMWDuitslandMercedesDuitslandAudiDuitslandPorscheDuitslandVWDuitslandSeatSpanjeAston MartinEngelandJaguarEngelandRange RoverEngelandBentleyEngelandRolls RoyceEngelandRenaultFrankrijkPeugeotFrankrijkCitroenFrankrijkFiatItalieFerrariItalieMaseratiItalieLamborghiniItalieKiaKoreaToyotaJapanNissanJapanHoldenAustralie as boolean
at anywheresoftware.b4a.BA.parseBoolean(BA.java:335)
at anywheresoftware.b4a.BA.ObjectToBoolean(BA.java:402)
at automerk.land.main._httpc_responsesuccess(main.java:351)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:113)
at anywheresoftware.b4a.BA$1.run(BA.java:218)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3701)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
at dalvik.system.NativeStart.main(Native Method)
java.lang.RuntimeException: Cannot parse: Alfa RomeoItalieBMWDuitslandMercedesDuitslandAudiDuitslandPorscheDuitslandVWDuitslandSeatSpanjeAston MartinEngelandJaguarEngelandRange RoverEngelandBentleyEngelandRolls RoyceEngelandRenaultFrankrijkPeugeotFrankrijkCitroenFrankrijkFiatItalieFerrariItalieMaseratiItalieLamborghiniItalieKiaKoreaToyotaJapanNissanJapanHoldenAustralie as boolean

b4a code:

B4X:
Sub Process_Globals
    Dim httpC As HttpClient 'the Connection client
   End Sub

Sub Globals
   Dim pnlbg As Panel  ' background panel
   Dim btnsubmit As Button ' Send to DB
    Dim btncallDB As Button ' Retrieve from DB
      Dim txtinput As EditText ' Text entry field
   Dim lvoutput As ListView ' Show the messages from the DB
    Dim reader As TextReader ' reading the text from the DB 
      
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("main")
   httpC.Initialize("httpC")
      
   'keeps it transparent wehn you scroll to see the text
   lvoutput.ScrollingBackgroundColor = Colors.Transparent
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)
   
End Sub

Sub btncallDB_Click
Dim req As HttpRequest ' requesting net data

req.InitializeGet("http://mysqlandroid.webatu.com/Automerk.php?action=getall")
    httpC.Execute(req, 1)
    ProgressDialogShow("Fetching all data...")
End Sub

Sub httpC_ResponseSuccess (Response As HttpResponse, TaskId As Int)

    lvoutput.Clear
   'download results 
   Dim result As String
    result = Response.GetString("UTF8")
   
   'strip out the underscores
   result = result.Replace("_"," ")
   
   
   'write it to a file
   File.WriteString(File.DirInternalCache, "automerk.txt",result)
   'get it back from the file
   reader.Initialize(File.OpenInput(File.DirInternalCache, "automerk.txt"))
    
   Dim Merk, Land As String
   Merk = reader.ReadLine
   Land = reader.ReadLine
   
    Dim i As Int :i = 0
   
    Do While Merk, Land <> Null
     i = i+1
    
   Dim linetext As String
   linetext = reader.ReadLine
   
      lvoutput.SingleLineLayout.Label.TextSize =  16
      lvoutput.SingleLineLayout.ItemHeight = 35
      lvoutput.SingleLineLayout.Label.TextColor = Colors.Black
      lvoutput.AddSingleLine(i&" "& Merk & Land &" "& linetext)
      
        Merk = reader.ReadLine
      Land = reader.ReadLine
   Loop
   
   reader.Close
        ProgressDialogHide
        lvoutput.SetSelection(0)
End Sub   

Sub lvoutput_ItemClick(Position As Int, Value As Object)
Msgbox(Value, "Message")
End Sub

Sub httpC_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
    Msgbox("Error connecting to server"&CRLF&CRLF&Reason,"Error ("&StatusCode&")")
    ProgressDialogHide
End Sub

'SUBMIT MESSAGE
Sub btnsubmit_click

Activity.Title = "Submitted"
'Log(deviceID)
Dim inputtext As String
inputtext = txtinput.Text

If inputtext <>"" Then
inputtext = inputtext.Replace(" ", "_")

ProgressDialogShow("Submitting data...")
Dim req As HttpRequest
      
sendrequest = "http://mysqlandroid.webatu.com/Automerk.php?action=add&Merk&Land=" 
      
req.InitializeGet(sendrequest & "" &"&text=" & inputtext)

      httpC.Execute(req, 1)
      
Else
ToastMessageShow("Put a message in first", False)
End If

'clear the text box
txtinput.Text = ""
End Sub

Note: attached images: error on my phone and testing my db connection via browser
 

Attachments

  • browser test database.png
    browser test database.png
    48.3 KB · Views: 228

Asmoro

Active Member
Licensed User
Longtime User
Thanks nfordbscndrd,

Tried your suggestion, but get this (see image) instead.
At least no log error this time and a little progress.
So I'll continue searching...

Anyone else??
 

Attachments

  • screen_20120626_1449.jpg
    screen_20120626_1449.jpg
    25.8 KB · Views: 210
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
If I execute http://mysqlandroid.webatu.com/Automerk.php?action=getall, I receive a large string with models and countries. BUT I don't see how you can process this string, since I don't see a split-character. For e.g. I see BMWDuitslandMercedesDuitsland. How can you split this result? I think you have to add a special character (I don't know, perhaps something like a comma) so when you receive the result, you can use regex.split in order to split your result and add every single item in your file. This of course has to be done by your php code too. When you make an insertion or/and when you get the results. For e.g. if you are reading from a mySQL database, in the process of gathering your results, you should insert a "," in between.
 
Upvote 0

Asmoro

Active Member
Licensed User
Longtime User
Your original problem was that you were getting an error. You made the suggested change and you are no longer getting an error. So what is it that you are going to keep searching for?

I expected after the fixed error to get a list retrieved from the database.
But unfortunately I get a tiny part of it displaying in the listview.
So that's why I'm digging further what the problem could be.

Update:
@nfordbscndrd and mc73: thanks for the big help.
I finally found the list error. It has something to do within the php script that I forgot to put in:

B4X:
 while($row = mysql_fetch_array($result)){ 
    echo "\r\n".$row['Merk'];
    echo "\r\n".$row['Land']."\r\n";
 
Last edited:
Upvote 0
Top