1

嘿,我正在尝试以下 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是要插入的值有什么办法吗?

4

2 回答 2

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')") 
于 2012-04-08T14:52:04.987 回答
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

于 2012-04-08T14:59:00.497 回答