Sunday, May 20, 2018

mysql error unknown column in field list



Hey I'm tring the following sql query :



$sql = mysql_query("INSERT INTO feeds (FileLocation,Title,feeddate,nameofuploader,type) 

VALUES('".mysql_real_escape_string($putItAt)."','".mysql_real_escape_string($_POST['title'])." ',now(),". $_SESSION['name'] .",'file')")


but its giving me the error:
Unknown column 'Ankit2' in 'field list'
where Ankit2 is the value to be inserted
Any way around this?


Answer



You forgot to put single quotes around the $_SESSION variable!




$sql = mysql_query("INSERT INTO feeds (FileLocation,Title,feeddate,nameofuploader,type) 
VALUES('".mysql_real_escape_string($putItAt)."','".mysql_real_escape_string($_POST['title'])." ',now(),'". $_SESSION['name'] ."','file')")

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...