Android Question Building your own Local Server with XAMPP and b4A(using MYSQL Database)

ilan

Expert
Licensed User
Longtime User
i try this post https://www.b4x.com/android/forum/t...-local-php-mysql-server-xampp-with-b4a.48635/
i got an error undefine key "action". should i give input manually in XAMMP mysql database?
why do you want to use PHP? connect directly to your sql db using jRDC2
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
Upvote 1

suciwulans

Active Member
Licensed User
Longtime User
why do you want to use PHP? connect directly to your sql db using jRDC2
i saw this post using B4J server not XAMMP. so i decide to use PHP. unfortunately error code display when use this on browser 127.0.0.1/persons/persons.php
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Check my code Snippets which is based on the above post by Kmatle
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
From that post, in the php script you have:
B4X:
$action = $_GET["action"];
switch ($action)
Please read
$_GET can also collect data sent in the URL.

Assume we have an HTML page that contains a hyperlink with parameters:

In that post script, you have:
B4X:
switch ($action)

And "action" can be: CountPersons, GetPersons or InsertNewPerson.
i got an error undefine key "action"
So, you have to define action in the URL when you call your script, something like this (assuming you're testing in the computer you're running xampp)
B4X:
http://localhost/persons.php?action=CountPersons
 
Upvote 1

aeric

Expert
Licensed User
Longtime User
Since you are posting in B4A forum, I assume you made a mistake in B4A code when calling the PHP web service.

Here is an example:
B4X:
Dim job As HttpJob
job.Initialize("", Me)
job.Download2("http://192.168.50.6/persons/persons.php", Array As String("action", "CountPersons"))
Wait For (job) JobDone (job As HttpJob)
If job.Success Then    
    Log(job.GetString)
Else
    Log(job.ErrorMessage)
End If
job.Release

edit: URL edited
 
Upvote 0

suciwulans

Active Member
Licensed User
Longtime User
Since you are posting in B4A forum, I assume you made a mistake in B4A code when calling the PHP web service.

Here is an example:
B4X:
Dim job As HttpJob
job.Initialize("", Me)
job.Download2("http://192.168.50.6/persons/persons.php", Array As String("action", "CountPersons"))
Wait For (job) JobDone (job As HttpJob)
If job.Success Then   
    Log(job.GetString)
Else
    Log(job.ErrorMessage)
End If
job.Release

edit: URL edited
oke i try right now
 
Upvote 0
Top