2015-09-19 69 views
-1

有人可以請幫助我這個語法有什麼問題。 當我運行這個,它不會將值插入到表中。什麼是錯誤的MySql語法,

目前所有的變量e.g $land,等有一個值。 在我的數據庫表中,除$nOwners,$id(int)之外的所有數據都被定義爲varchar,。

詳情: 我使用Mysqli

$sql= "INSERT into property_list (id, title_no, status, register_type, type,land_district, issue_date,guarantee_status,provisional,title_no_srs,title_no_head_srs, survey_reference, Maori_land, number_owners) 
     VALUES($id,'$title', '$status', '$register', '$type', '$land', '$issue_date', '$guarantee', '$provision', '$title_no_srs','$head_srs', '$survery', '$maori', $nOwners)"; 


if($conn->query($sql)!==false) 
{ 
    $flag=false; 
    echo "successfully inserted "; 
} 
+0

[強制性](http://bobby-tables.com/)。 – Amadan

+0

^義務?這寫在哪裏?我不記得籤合同了;-) ...或者,我呢? –

+0

在我心中。每當有人犯下不轉義變量而不使用預先準備好的陳述時,Bobby表必須被鏈接。這是一部法律。 – Amadan

回答

-1

嗯,列名的地位可能是一個問題,它是SQL保留關鍵字。嘗試另一個名字,看看是否修復它。 https://www.drupal.org/node/141051

+2

'name'是一個關鍵字,而不是一個保留字https://dev.mysql.com/doc/refman/5.5/en/keywords.html - 注意'(R)'不是下一個到它? –

+0

這不是我downvote順便說一句。我剛纔注意到了。 –

+0

https://www.drupal.org/node/141051 *「SQL保留字列表」* - SQL不是MySQL。那些是兩個不同的動物。注意到鏈接http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html與您的鏈接在同一頁上? –