I wrote to code to fetch data from the mysql
database,
<?php
$host="localhost";
$user="root";
$pass="";
$database="users";
$con=mysqli_connect($host,$user,$pass) or die ("connection failure");
$day="Mon";
$status="false";
$timeInterval="08-10";
mysqli_select_db($con,$database) or die("databaseconnection error");
$result=mysqli_query($con,"SELECT hallId FROM lectureHall WHERE status=$status AND day=$day AND timeInterval=$timeInterval");
while($row=mysqli_fetch_assoc($result)){
$tmp[]=$row;
}
echo json_encode($tmp);
mysqli_close($con);
?>
this code gives me a warning, displaying:
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result null given
However, when I give values directly without variable passing like this
$result=mysqli_query($con,"SELECT hallId FROM lectureHall WHERE status='false' AND day='Mon' AND timeInterval='08-10'");
It gives results, why variable passing code doesn't work? is there is a special way to pass String
values to a query
. Variable passing is needed, as I am going to give values for these variables through Java
HTTP post` please help me to fix this. Thanks in advance