-4
嗨我在php中運行我的代碼時不斷收到SQL語法錯誤,但是當我刪除變量並在MYSQL中手動執行時,沒有問題。我試圖用(')2個不同版本的查詢一個和其他與(「),並沒有什麼。你能幫?你的SQL語法有錯誤;檢查與您的MySQL服務器版本相對應的手冊
謝謝。
$produpdateid = $_GET ['id'];
$varcat = $_POST['category'];
$vartitle = strip_tags($_POST['title']);
$varoverview = strip_tags($_POST['overview']);
$varfeatures = strip_tags($_POST['features']);
$varspecification = strip_tags($_POST['specification']);
$varmaker = strip_tags($_POST['maker']);
$varsize = $_POST['size'];
$varprice = $_POST['price'];
$varstock = $_POST['stock'];
$vartype = $_POST['stock'];
$q = 'UPDATE products SET products_category_id=' . $varcat . ', title=' . $vartitle . ', overview=' . $varoverview . ', features=' . $varfeatures . ', specification=' . $varspecification . ', size=' . $varsize . ', size_type=' . $vartype . ', maker=' . $varmaker . ', image=' . $varimg . ', price=' . $varprice . ', stock=' . $varstock .' WHERE id=' .$produpdateid;
/*$test = "UPDATE products SET products_category_id=" . $varcat . ", title=" . $vartitle . ", overview=" . $varoverview . ", features=" . $varfeatures . ", specification=" . $varspecification . ", size=" . $varsize . ", size_type=" . $vartype . ", maker=" . $varmaker . ", image=" . $varimg . ", price=" . $varprice . ", stock=" . $varstock ." WHERE id=" .$produpdateid;*/
$updateresult = mysqli_query($dbc,$q);
你可能需要引用值。另外:瞭解[*預處理語句*](http://j.mp/T9hLWi) – PeeHaa
[你真的需要逃避你的變量。 。](http://xkcd.com/327/) –
試圖逃避變量,什麼也沒有,相同的錯誤 – user1810442