I have a simple example, where I want to connect to MySQL using WAMP Configure WAMP and manage to connect with MySQL, where I create a database to which I want to connect from Android In WAMP add a .php file with the user and pass data to connect to the database, which I use from Android :
<?php
error_reporting (E_ALL ^ E_NOTICE ^ E_DEPRECATED);
$databasehost = "localhost";
$databasename = "basedatosempresa";
$databaseusername ="Admin";
$databasepassword = "1234";
$con = mysqli_connect( $databasehost,$databaseusername,$databasepassword, $databasename ) or die(mysql_error());
mysql_set_charset("utf8");
mysql_select_db($databasename) or die(mysql_error());
$query = file_get_contents("php://input");
$sth = mysql_query($query);
if (mysql_errno()) {
header("HTTP/1.1 500 Internal Server Error");
echo $query.'\n';
echo mysql_error();
}
else
{
$rows = array();
while($r = mysql_fetch_assoc($sth)) {
$rows[] = $r;
}
print json_encode($rows);
}
?>
Code B4A
Sub Buscar_lista_de_paises
ProgressDialogShow("Buscando lista de países.")
Dim req As OkHttpRequest
Dim Query As String
Query="SELECT nombre, ID FROM paises ORDER BY ID"
req.InitializePost2("http://192.168.0.12/paises.php", Query.GetBytes("UTF8"))
hc.Execute(req, paises) '''''''' En ResponseSuccess hará el Case de paises
End Sub
But it gives me the following error:
Error: java.net.UnknownServiceException: CLEARTEXT communication to 192.168.0.12 not permitted by network security policy, StatusCode: -1
Please your help or indications, because I do not know what else to investigate
<?php
error_reporting (E_ALL ^ E_NOTICE ^ E_DEPRECATED);
$databasehost = "localhost";
$databasename = "basedatosempresa";
$databaseusername ="Admin";
$databasepassword = "1234";
$con = mysqli_connect( $databasehost,$databaseusername,$databasepassword, $databasename ) or die(mysql_error());
mysql_set_charset("utf8");
mysql_select_db($databasename) or die(mysql_error());
$query = file_get_contents("php://input");
$sth = mysql_query($query);
if (mysql_errno()) {
header("HTTP/1.1 500 Internal Server Error");
echo $query.'\n';
echo mysql_error();
}
else
{
$rows = array();
while($r = mysql_fetch_assoc($sth)) {
$rows[] = $r;
}
print json_encode($rows);
}
?>
Code B4A
Sub Buscar_lista_de_paises
ProgressDialogShow("Buscando lista de países.")
Dim req As OkHttpRequest
Dim Query As String
Query="SELECT nombre, ID FROM paises ORDER BY ID"
req.InitializePost2("http://192.168.0.12/paises.php", Query.GetBytes("UTF8"))
hc.Execute(req, paises) '''''''' En ResponseSuccess hará el Case de paises
End Sub
But it gives me the following error:
Error: java.net.UnknownServiceException: CLEARTEXT communication to 192.168.0.12 not permitted by network security policy, StatusCode: -1
Please your help or indications, because I do not know what else to investigate