I am using android volley library to get the records from database on server. I send a query from my android app to this php script. When I write query myself in 4th line as follows $myquery = "Select firstname from Student;"; then all results are returned correctly but when I send a query directly, it doesn't returns records. I am sure that the issue is in php script, please help me where I am going wrong in this basic script?
function showStudent()
{
global $connect;
$myquery = $_POST["query"];
$result = mysqli_query($connect,$myquery);
$number_of_rows = mysqli_num_rows($result);
$temp_array = array();
if($number_of_rows>0)
{
while( $row = mysqli_fetch_assoc($result) )
{
$temp_array[] = $row;
}
}
header('Content-Type: application/json');
echo json_encode(array("dataArray"=>$temp_array));
mysqli_close($connect);
}
?>
Change to this
$myquery = $_REQUEST['query'];
Instead of this
$myquery = $_POST["query"];