2011-06-04 216 views
0

您是否在此插入中看到錯誤?php mySQL插入問題

它不爲我工作..

$insSubm = "INSERT INTO cR_Submissions memberID ='".$memberID."', RefNumb='".$RefNumb."', title ='".$title."', CopyRightNumb='".$copyRightNumbWork."', type='".$natureTypeWork."', OtherTitle='".$alternateTitleWork."', OwnershipTransfer='".$textareaPrior."', Status ='".$status."', DateWhen='".$todaydate."', Time='".$NowisTime."'"; 
$resultinsSubm=mysql_query($insSubm) or die("Error insert Submissions: ".mysql_error()); 

我是瞎了?

請幫

感謝

+0

什麼的'mysql_error()'返回?另請注意,您正在使用替代的'INSERT'語法,這可能在您的版本中不受支持。 – 2011-06-04 15:09:54

回答

4

這是無效的SQL語法。 SQL語法是:

INSERT INTO table (field1, field2, ..., fieldN) VALUES (val1, val2, ..., valN) 

的替代MySQL的語法是這樣的:

INSERT INTO table SET field1 = val1, field2 = val2, ..., fieldN = valN 

你錯過了SET關鍵字。查看INSERT Syntax文檔瞭解更多信息。

0

查詢應該是這樣的......

$insSubm = " 
    INSERT INTO `cR_Submissions` (`memberID`, ...) 
    VALUES ('" . $memberID . "', ...)"; 
0

變化用下面的代碼代碼:

$insSubm = "INSERT INTO cR_Submissions (memberID, RefNumb, title, CopyRightNumb, type, OtherTitle, OwnershipTransfer, Status, DateWhen, Time) 
      VALUES ('$memberID', '$RefNumb', '$title', '$copyRightNumbWork', '$natureTypeWork', '$alternateTitleWork', '$textareaPrior', '$status', '$todaydate', '$NowisTime');"; 

$resultinsSubm = mysql_query($insSubm) or die("Error insert Submissions: ".mysql_error());