You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version

Posted by user1810442 on Stack Overflow See other posts from Stack Overflow or by user1810442
Published on 2012-11-13T22:54:21Z Indexed on 2012/11/13 22:59 UTC
Read the original article Hit count: 173

Filed under:
|
|
|

Hi I keep getting SQL syntax error when i'm running my code in php, however when i remove the variables and do it manually in MYSQL, not a problem. I've tried 2 different versions of query one with (') and other with (") and nothing. Could you please help?

Thank you.

            $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);

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql