Android Question Connect Android to MySQL using Wamp

msuzanne

Member
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
 

josejad

Expert
Licensed User
Longtime User
Please your help or indications, because I do not know what else to investigate
Write "CLEARTEXT" in the forum search, (or any other error you get) it will give you a lot of hints:

1626328153609.png


When publishing code, use [code].... Paste your code here ... [/code], it will make the post more clear.

You can do it too with the menu:

1626328278446.png
 
Upvote 0
Top