0

I am passing array in query to fetch the results.I am using IN operator of SQL for this purpose.As per SQL syntax it should be IN('value1','Value2');. I am using following code create & execute query.

   $categories=array();
    $categories=$_GET['category'];


$query = 'SELECT * from postdata Where category IN (" . implode(',', $categories) . ")';

echo $query;

$run = mysql_query($query);
if(!$run)
{
echo "query failed";
echo mysql_error();
}
else
{
echo "not failed";
}

My query print like this.

SELECT * from postdata Where category IN (Activated)

No quotes for inside IN in query is this reason my query fails?

TechChain
  • 8,404
  • 29
  • 103
  • 228

0 Answers0