higfox
higfox

Reputation: 87

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?

Upvotes: 1

Views: 7526

Answers (2)

Veelion Chong
Veelion Chong

Reputation: 23

Is the sql string right? Please try this to check your sql string:

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

to check the sql_st

Upvotes: 1

Mortana
Mortana

Reputation: 1442

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')") 

Upvotes: 7

Related Questions