Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Apr 2011
    Posts
    49
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Question PHP mysql update row syntax error

    Hi All,

    Just trying to do a simple product edit page and for some reason it is giving the following error:

    Code:
    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 'desc = 'This is the Pro Range Hoodie which is available in a variety of sizes in' at line 1
    Here is the mysql part of the code, I know its probably something simple but i just cant seem to find it
    PHP Code:
    if(!isset($_FILES['image'])) {
                            
    $updatewithnewimage mysql_query("UPDATE `products3` SET `title` = $product_name,  `club_id` = $product_club, `price` = $product_price, `product_range` = $product_range, `size_type` = $product_size, `imagename` = $product_image, `desc` = $product_desc WHERE `id` = $editid ") or die(mysql_error());
                        echo 
    "product added with new image";
                        }
                        else {
                        
    $updatewitholdimage mysql_query("UPDATE products3 SET title = '$product_name', club_id = '$product_club', price = '$product_price', product_range = '$product_range', size_type = '$product_size', imagename = '$old_product_image', desc = '$product_desc' WHERE id = '$editid' ") or die(mysql_error());
                        echo 
    "product added with old image";
                        } 
    Last edited by tim967; 04-26-2013 at 04:10 PM. Reason: resolved! big thanks!

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    DESC is a mysql keyword. In your first query you have put back-ticks around it but there's no back-ticks in your second query.

    PS: Using mysql keywords as the names of table/field is considered as a bad practice.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    tim967 (04-26-2013)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •