Home » Php » php – mysql select error using where <VARCHAR(70)>

php – mysql select error using where <VARCHAR(70)>

Posted by: admin February 25, 2020 Leave a comment

Questions:

I am trying to fetch data from mysql table :

Here is my code:
rec_id is a VARCHAR(70)

$sql="SELECT rec_id,message,ts FROM msg WHERE rec_id = '". $_SESSION['userData']['id']."'";

$result=mysqli_query($conn,$sql);

where the session data contains id i.e 259137558442865

The query is fetching empty result.
But on removing ‘(single quotes)’ after WHERE around session var, the query works in SQL but still not in php.
Please help

How to&Answers: