$name=$_GET['name'];
$sql="SELECT `productname`, `price` FROM `stock` WHERE productname=".$name."
and ( userid=".$_SESSION['user_id']." or userid='100')";
Basically I am getting product name from one page. I am passing query where productname is the $name and the userid is either the current signed one or the admin userid (100).
But I am getting error
Notice: Undefined variable: productname in /path_to_file.php on line 431
line 431: <?php echo $productname;?>
where $productname=$row['productname'];
I sense something is wrong in sql query. But what is wrong?