Some Query Issue



This is my query…,


echo $sql="SELECT * FROM `products`  
                         where (school_id is null or school_id=:sschoolnamenew) AND
                        (pcat_id is null or pcat_id= :spname) ";

  $query = $conn->prepare($sql);

$query->bindParam(':sschoolnamenew', $sschoolnamenew);
$query->bindParam(':spname', $spname);

But it wont run what i did wrong…?

any suggestion please…


Two thoughts.

  1. does the query run when you run it manually against the database?
  2. When you run it, are you using the same values that are passed in with these variables?
echo "sschoolnamenew: {$sschoolnamenew} spname: {$spname}";