Android Question Problem regarding running php script

saeed10051

Active Member
Licensed User
Longtime User
Hi, i am trying to run a php script by using following code

Dim j As HttpJob
j.Initialize("", Me)
'j.PostString("http://saeedhassan.atwebpages.com/r.php", query)
j.Download("http://saeedhassan.atwebpages.com/r.php")
Wait For (j) jobdone (j As HttpJob)
If j.Success Then
Log(j.GetString)
End If
I am getting following error whenever i run it
ResponseError. Reason: java.net.UnknownServiceException: CLEARTEXT communication to saeedhassan.atwebpages.com not permitted by network security policy, Response:
i have a paid basic plan and i have checked with the site team, they say that the outgoing http request is allowed.
Also when i run this script on a web browser by pasting http://saeedhassan.atwebpages.com/r.php in the browser , it runs and returns the json string.
I am using following php code

<?php
$conn = new mysqli("pdb48.awardspace.net", "3373050_pivot", "K8888882058@", "3373050_pivot");

if ($conn->connect_error) {
die("ERROR: Unable to connect: " . $conn->connect_error);
}

echo 'Connected to the database.<br>';

$result = $conn->query("SELECT * FROM menuitems");

//echo "Number of rows: $result->num_rows";


if ($result->num_rows > 0) {
// output data of each row
$rows = array();
while($r = $result->fetch_assoc()) {
$rows[] = $r;
}
} else {
echo "0 results";
}
$res = json_encode($rows);
echo $res;
$result->close();

$conn->close();
?>

can anyone please help me out in this.
 

drgottjr

Expert
Licensed User
Longtime User
no problem running it here.
Connected to the database.<br>[{"itemid":"1","itemname":"chicken biryani","itemprice":"20"},{"itemid":"2","itemname":"mutton biryani","itemprice":"25"},{"itemid":"3","itemname":"rice","itemprice":"10"},{"itemid":"4","itemname":"chicken qorma","itemprice":"15"},{"itemid":"5","itemname":"mutton qorma","itemprice":"25"},{"itemid":"6","itemname":"naan","itemprice":"2"},{"itemid":"7","itemname":"vegetable","itemprice":"8"},{"itemid":"8","itemname":"daal","itemprice":"8"},{"itemid":"9","itemname":"egg","itemprice":"5"},{"itemid":"10","itemname":"egg sandwich","itemprice":"10"},{"itemid":"11","itemname":"tea","itemprice":"1"},{"itemid":"12","itemname":"coffee","itemprice":"3"},{"itemid":"13","itemname":"sweet","itemprice":"10"},{"itemid":"14","itemname":"donut","itemprice":"5"},{"itemid":"15","itemname":"water","itemprice":"1"},{"itemid":"16","itemname":"pizza","itemprice":"30"},{"itemid":"17","itemname":"ice cream","itemprice":"7"}]

are you running this on android 9 or 10? you have to make a manifest setting. i'm looking for it now. maybe somebody else will find it first...
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
This one drgottjr:

 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
here:
Add this line to your Manifest:
SetApplicationAttribute(android:usesCleartextTraffic, "true")

thanks, jose! saw your message too late 👍
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
Comment this code:

//echo 'Connected to the database.<br>';

JSON:
Connected to the database.
[{"itemid":"1","itemname":"chicken biryani","itemprice":"20"},{"itemid":"2","itemname":"mutton biryani","itemprice":"25"},{"itemid":"3","itemname":"rice","itemprice":"10"},{"itemid":"4","itemname":"chicken qorma","itemprice":"15"},{"itemid":"5","itemname":"mutton qorma","itemprice":"25"},{"itemid":"6","itemname":"naan","itemprice":"2"},{"itemid":"7","itemname":"vegetable","itemprice":"8"},{"itemid":"8","itemname":"daal","itemprice":"8"},{"itemid":"9","itemname":"egg","itemprice":"5"},{"itemid":"10","itemname":"egg sandwich","itemprice":"10"},{"itemid":"11","itemname":"tea","itemprice":"1"},{"itemid":"12","itemname":"coffee","itemprice":"3"},{"itemid":"13","itemname":"sweet","itemprice":"10"},{"itemid":"14","itemname":"donut","itemprice":"5"},{"itemid":"15","itemname":"water","itemprice":"1"},{"itemid":"16","itemname":"pizza","itemprice":"30"},{"itemid":"17","itemname":"ice cream","itemprice":"7"}]
 
Upvote 0
Top