Sunday 20 May 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

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...