I have following sql query in PHP and output is as JSON:
<?php
$user_id = "1";
$sql = 'SELECT *,DATE_FORMAT(c.`date`, "%d.%m.%Y") AS date
FROM
conversation c,
users u
WHERE
c.user_two = u.uid AND c.user_one = '$user_id'
ORDER By c.precious_time DESC';
$result = mysqli_query($con, $sql);
$rows = array();
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
$rows [] = $row;
}
mysqli_close($con);
echo json_encode($rows);
?>
When I execute the the php file it does not echo anything, but if I set c.user_one = "1" instead of c.user_one = '$user_id' then it works and it gives me the results. Is there a formatting error ?