大家好我有一個字段「ammount」在mysql數據庫中有「varchar(50)」類型。當我插入數據到該領域例如ammount = 4公斤它確定但當我更新該字段時,它給了我以下錯誤。更新查詢問題
Error in query: UPDATE ingredients SET ingredient_name='test recipe',ammount=4 gm where ingredient_id='59'. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'gm where ingredient_id='59'' at line 1
和我的查詢是
$query="UPDATE ingredients SET ingredient_name='$ingredient',ammount=$ammount where ingredient_id='$ingredient_id'";
它會「工作」,但請不要這樣做!如果`$ amount`來自用戶,他可以將其設置爲''; DROP TABLE成分; - ,他擦掉了你的桌子。 – 2010-12-02 07:02:18
您如何確定'$ ammount`在查詢中被使用之前未經過清理? – codaddict 2010-12-02 07:04:46