Tiny MySQL question

Bas Hamstra

Member
Licensed User
Longtime User
The following works fine:

B4X:
job1.Download2("http://84.84.231.194/test.php", Array As String("query","select UserID from usersonline"))

But how to get this working:

B4X:
job1.Download2("http://84.84.231.194/test.php", Array As String("query","select UserID from usersonline where UserID='Hamstra'"))

It connects to a MySQL database via PHP. I browsed the fora but couldn't find it.

Thousand thanks for a quick answer:sign0060:

Bas Hamstra
 

Bas Hamstra

Member
Licensed User
Longtime User
This is the PHP script

<?php
$mysqlDatabaseName = "gameroom";
$mysqlUsername = "root";
$mysqlPassword = "";

mysql_connect('localhost', $mysqlUsername, $mysqlPassword) or die(mysql_error());

mysql_select_db("gameroom") or die(mysql_error());


if(isset($_GET['query']))
{ $Query = $_GET['query'];
$Query = mysql_real_escape_string($Query);
$Result = mysql_query($Query);

$rows = array();
while($r = mysql_fetch_assoc($Result))
{ $rows[] = $r;
}
echo json_encode($rows);
}


?>
 
Upvote 0

Bas Hamstra

Member
Licensed User
Longtime User
Found the answer

Anyone interested? I can now fire ANY query as a simple string.

Query="Select * from usersonline where UserID = 'Hamstra'"
Query="Select * from usersonline where LoggedIn = 1'"
Query = "Select * from usersonline where UserID like '%a%'"
Query = "Select * from usersonline where UserID < 'Z'"

All tested and work.

Bas
 
Last edited:
Upvote 0
Top