php - Cookie through a form and GET -
i using $_get function carry database field forward throughout form. have come across stumbling block when try pull information database:
<?php $prodname=$_get["q"]; ?> <h3>product name: <u><?php echo $prodname; ?></u></h3><br /> <?php $con = mysql_connect("localhost","cl49-vogalcms","vogalcms"); if (!$con) { die('could not connect: ' . mysql_error()); } $prodname=$row['prodname']; $catagory=$row['catagory']; @mysql_select_db("cl49-xxx",$con)or die('unable select database ln 60:'.mysql_error()); $result=mysql_query("select * products prodname=$prodname")or die('ln 61 :'.mysql_error()); $cnt=$_cookie["count"]; setcookie("user",$myid,time()+10000); mysql_close($con); ?> <form name="newad" method="post" enctype="multipart/form-data" action="drtsavepic.php?q=<?php echo"$prodname"; ?>"> <br> <br> <input type="file" name="image"> <input name="submit" type="submit" value="upload image"> </form>
when run code, following error
ln 61 :you have error in sql syntax; check manual corresponds mysql server version right syntax use near '' @ line 1
can shine light on issue?
try replacing mysql_query("select * products prodname=$prodname")
by
mysql_query("select * products prodname='".$prodname."'")
Comments
Post a Comment