i m trying to get a json for my android application but i m getting an error:
mysqli_fetch_array() expects parameter 1 to be mysqli_result, object given in /home/a5872453/public_html/GetAllGreenhouse.php on line 17
this is my code:
<?php
$con=mysqli_connect("mysql3.000webhost.com","xxx","xxx","xxx");
$farmname = $_POST["farmname"];
$statement = mysqli_prepare($con, "SELECT * FROM GreenHouse WHERE farm_name = ?");
mysqli_stmt_bind_param($statement, "s", $farmname);
mysqli_stmt_execute($statement);
mysqli_stmt_store_result($statement);
mysqli_stmt_bind_result($statement, $ghid, $name, $farmname, $planttype, $linefrom, $lineto, $barcode);
$response["greenhouses"] = array();
while($row = mysqli_fetch_array($statement)){
$greenhouse= array();
$greenhouse["ghid"]=$row[$ghid];
$greenhouse["name"]=$row[$name];
$greenhouse["farmname"]=$row[$farmname];
$greenhouse["planttype"]=$row[$planttype];
$greenhouse["linefrom"]=$row[$linefrom];
$greenhouse["lineto"]=$row[$lineto];
$greenhouse["barcode"]=$row[$barcode];
// push single product into final response array
array_push($response["greenhouses"], $greenhouse);
}
echo json_encode($response);
mysqli_stmt_close($statement);
mysqli_close($con);
?>