I'm creating an android project that receives data from PHP side. But the PHP code gives no result.
I wrote this php code and checked it goes to else loop and shoes no people found . But my SQL query gives output in XAMPP SQL manually.
if($_SERVER['REQUEST_METHOD']=='POST'){
include_once "Dbconnect.php";
$phone= $_POST['phn'];
$sql="Select
peoples.name as pname,
peoples.address as addr,
peoples.phone as phone,
peoples.nomineephone as nphone,
peoples.idproofnumber as idproof,
camp.campid as cid,
camp.Managername as mgrname,
camp.managerno as mgrphone,
camp.name as cname,
camp.Location as loc
from
peoples
inner join camp
on peoples.campid=camp.campid
where
peoples.phone='$phone'";
$result = $conn->query($sql);
if ($result->num_rows >0) {
while($row[] = $result->fetch_assoc()) {
$tem = $row;
$json = json_encode($tem);
}
} else {
echo 'No people data found';
}
echo $json;
}
i tried to echo the phone number in PHP side i got the phone number from android and the data is available in DB with that phone number. But this code not giving the data. I expect the output of the query as json in android
var_dump($result)? Have you checked your error logs? You also need to escape your inputs better.if($_SERVER['REQUEST_METHOD']=='POST'){condition? 2.Make surephonehas the value 3.echo$sqland try to execute it in phpmyadmin and make sure thephonenumber existing in DBSELECT * FROM peoples WHERE peoples.phone='+1-555-867-5309'? With a hard coded number. Just as to verify stuff is working and then build upon it one step at a time? Oh. If the phone numbers are strings, then it would be.phone LIKE 'phone-string'.