1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Cannot update mysql database

Discussion in 'PHP' started by countrydj, Apr 11, 2011.

  1. #1
    Hi Guys...

    I'm having problems with my coding.
    Here is the problem:
    I have a database with a list of products.
    I can list all the products OK
    At the side of each product I have an EDIT and DELETE button.
    The delete button works fine and deletes the item.
    The EDIT button displays a form with all the details from the database.
    I can then edit this form and click on UPDATE.
    This is the code that I have to update the database:

    $group = $_REQUEST['group'];
    $description = $_REQUEST['description'];
    $quantity = $_REQUEST['quantity'];
    $price = $_REQUEST['price'];
    $type = $_REQUEST['type'];
    $type2 = $_REQUEST['type2'];
    $order = $_REQUEST['order'];
    $status = $_REQUEST['status'];


    $qry = "UPDATE " . $vars["table directory"] . " SET ";
    $qry .= "group = '$group', ";
    $qry .= "description = '$description', ";
    $qry .= "quantity = '$quantity', ";
    $qry .= "price = '$price', ";
    $qry .= "type = '$type', ";
    $qry .= "type2 = '$type2', ";
    $qry .= "order = '$order', ";
    $qry .= "status = '$status' ";
    $qry .= "WHERE id = '$id'";


    I cannot see anything wrong with this code.

    But when I click on UPDATE (in the form), I get :

    Error in executing UPDATE exhausts SET group = 'Alloy Silencers', description = 'RS 125 Aprilia', quantity = '1', price = '57.00', type = 'alloy', type2 = 'all', order = '', status = '1' WHERE id = '3' query

    error:1064 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 'group = 'Alloy Silencers', description = 'RS 125 Aprilia', quantity = '1', price' at line 1


    I have used this code many time before in other projects without problems.

    Can anybody see a problem with the code, or anything that may be causing the problem.

    Any advice will be most welcome.
    It's doing my head in at the moment.

    Thanks,

    John C
     
    countrydj, Apr 11, 2011 IP
  2. denamurray

    denamurray Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Maybe column name mangling?
     
    denamurray, Apr 11, 2011 IP
  3. countrydj

    countrydj Active Member

    Messages:
    41
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #3
    Hi denamurray...

    Many thanks for taking the time and trouble to answer me.

    Thanks for this info.
    I have discovered that GROUP and ORDER is are reserved words.

    I have now changed GROUP and ORDER and it now works.

    Thank you,

    John C
     
    countrydj, Apr 11, 2011 IP