HttpUtils and MySQL / PHP

roarnold

Active Member
Licensed User
Longtime User
Evening,

Need a bit of help, and the big guys know I'm new at this, however, I have been working on an app to get a specific item from a MySQL DB through a php file. BTW: Been using Eclipse for six weeks or so and wanted a better way to build apps. So, B4A was it, like it but have questions that are not understandable.

While another individual helping with the app (works the SQL side) was helping debug we can get to the db but the Query that we set during debug shows some number and where it comes from we have no idea. Additionally, tried to use HttpUtils and keep getting an error telling me that HttpUtil variable was being used before initialized. I set it up per Erel's example just changing the link address.

app -

B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Dim hc As HttpClient
   Dim STUB As Int
   STUB = 1
   Dim fonee As Int
   fonee = 9093768439 - [B]number (phone) I am looking for if you look at the screenshot1 attachment from the debugger you will see the fonee is not the 909 number we were looking for[/B]
End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   
End Sub

Sub Activity_Create(FirstTime As Boolean)
  
   If FirstTime Then
      hc.Initialize("hc")
   End If
   Dim req As HttpRequest
req.InitializeGet("Http://......./android2.php")
hc.Execute(req, 1)
'ExecuteRemoteQuery("SELECT * FROM users WHERE phonenumber", fonee)
'Select * from users where phonenumber=[variable]
End Sub
Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int)
    Dim resultString As String
    resultString = Response.GetString("UTF8")
    'Work with the result
End Sub
Sub hc_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
    Log("Error connecting: " & Reason & " " & StatusCode)
    If Response <> Null Then
        Log(Response.GetString("UTF8"))
        Response.Release
    End If
End Sub 
'Sub ExecuteRemoteQuery (Query As String, TaskId As Int)
'   Query = fonee
'   Dim req As HttpRequest
'   req.InitializePost2("Http://...../android2.php", Query.GetBytes("UTF-8"))
'   hc.Execute(req, TaskId)
'End Sub
Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
 

Attachments

  • screenshot1.png
    screenshot1.png
    48.7 KB · Views: 201

roarnold

Active Member
Licensed User
Longtime User
There are two in the code

When I copied the screen I was in the middle of making changes.

You did not mention the HttpUtils portion?

Thx R
 
Upvote 0

roarnold

Active Member
Licensed User
Longtime User
Variable

You are right, adjusted the variable type and now able to get to the backend with what I am attempting to look for. I would like to clean it up with your utils package but am met with a bit of behind the curve so to speak.

I get an error from debug stating that I am utilizing vairable HttpUtils before it is initialized?

Thanks Again,
R
 
Upvote 0
Top