嘿,我正在尝试以下sql查询:
$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')")
但它给了我错误: '字段列表'中的未知列'Ankit2' 其中Ankit2是要插入的值 有什么方法吗?
答案 0 :(得分:7)
你忘了在$ _SESSION变量周围加上单引号!
$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')")
答案 1 :(得分:1)
sql字符串是对的吗?请尝试这样检查你的sql字符串:
$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;
检查sql_st