M msuzanne Member Jul 15, 2021 #1 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
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
KMatle Expert Licensed User Longtime User Jul 15, 2021 #2 Add this line to your Manifest: SetApplicationAttribute(android:usesCleartextTraffic, "true") Newer Android versions prevent not using SSL Upvote 0
Add this line to your Manifest: SetApplicationAttribute(android:usesCleartextTraffic, "true") Newer Android versions prevent not using SSL
josejad Expert Licensed User Longtime User Jul 15, 2021 #3 msuzanne said: Please your help or indications, because I do not know what else to investigate Click to expand... Write "CLEARTEXT" in the forum search, (or any other error you get) it will give you a lot of hints: 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: Upvote 0
msuzanne said: Please your help or indications, because I do not know what else to investigate Click to expand... Write "CLEARTEXT" in the forum search, (or any other error you get) it will give you a lot of hints: 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: