SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry mysql syntax error

    ice created an update script to allow the admin section on my site to update the product information, but im geting an error message as follows: ive included hopefully enough information, for some one to help obtain a solution to this problem. thanks in advance for ne help


    PHP Code:
    You have an error in your SQL syntaxCheck the manual that corresponds to your MySQL server version for the right syntax to use near 'actors = 'Daniel Radcliffe Emma Watson Rupert Grint Jason 
    here is the code for the query.

    PHP Code:
    if (isset($_POST['submit']) && $_POST['submit'] == "adjust") {
     
    $query_update "UPDATE user SET 
    product_name = '" 
    $_POST['product_name'] . "', 
    product_desc = '" 
    $_POST['product_desc'] . "', 
    product_price = '" 
    $_POST['product_price'] . "', 
    catid = '" 
    $_POST['catid'] . "', 
    quantity = '" 
    $_POST['quantity'] . "', 
    director = '" 
    $_POST['director'] . "' 
    actors = '" 
    $_POST['actors'] . "' 
    certificate = '" 
    $_POST['certificate'] . "' 
    WHERE productid = '" 
    $_POST['productid'] ."'"
    echo 
    "<br>";
    echo 
    $query_update;
    echo 
    "<br>";
    echo 
    "<br>";
      
    $result_update mysql_query($query_update
        or die(
    mysql_error()); 
    the following is what the query is storing:

    PHP Code:
    UPDATE user SET product_name 'Harry Potter And The Goblet Of Fire'product_desc 'Harry longs to get back inside the safe walls of Hogwarts School of Witchcraft and Wizardry, where Professor Dumbledore (Michael Gambon) can protect him. But things are going to be a little different this year. Dumbledore announces that Hogwarts will host the Triwizard Tournament, one of the most exciting and dangerous of the wizarding community\'s magical competitions. One champion will be selected from each of the three largest and most prestigious wizarding schools to compete in a series of life-threatening tasks in pursuit of winning the coveted Triwizard Cup...'product_price '14.99'catid '1'quantity '5'director 'Mike Newell' actors 'Daniel Radcliffe ; Emma Watson ; Rupert Grint ; Jason Isaacs ; Eric Sykes ; Timothy Spall ; David Tennant ; Mark Williams ; Robbie Coltrane ; Roger Lloyd-Pack ; Katie Leung ; Michael Gambon ; Maggie Smith ; Brendan Gleeson ; Gary Oldman ; Ralph Fiennes' certificate '12+' WHERE productid '1' 

  2. #2
    SitePoint Evangelist Waffles's Avatar
    Join Date
    Nov 2005
    Posts
    435
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dunno why your code is so bunched up but you missed a comma..

    director = 'Mike Newell' actors =

    should be

    director = 'Mike Newell', actors =


    PHP Code:

    <?
     UPDATE user SET product_name 
    'Harry Potter And The Goblet Of Fire'product_desc 'Harry longs to get back inside the safe walls...'product_price '14.99'catid '1'quantity '5'director 'Mike Newell'actors 'Daniel Radcliffe ...'certificate '12+' WHERE productid '1'

    ?>
    i deleted some stuff but you missed out 2 commas as far as i can tell

    soo..that tells me the input ain't right

  3. #3
    SitePoint Evangelist optl's Avatar
    Join Date
    Oct 2004
    Location
    Washington DC
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    director '" . $_POST['director'] . "'
    actors '" . $_POST['actors'] . "'
    certificate '" . $_POST['certificate'] . "' 
    change to:

    PHP Code:
    director '" . $_POST['director'] . "',
    actors '" . $_POST['actors'] . "',
    certificate '" . $_POST['certificate'] . "' 
    For the phrase "Bethesda home architect", my clients
    websites occupy 6 of the first 8 results
    on the 1st page of Google. My Secret SEO Strategy Revealed

  4. #4
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, cheers that sorted one prob out, but i then get the follwing error
    Unknown column 'productid' in 'where clause'
    , but i have a productid column in my table

  5. #5
    SitePoint Evangelist Waffles's Avatar
    Join Date
    Nov 2005
    Posts
    435
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    post your code in the new form, and try to space it out a little more?

  6. #6
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    its ok, i just spotted the mistake, it was in my table name. thanks once again

  7. #7
    SitePoint Evangelist Waffles's Avatar
    Join Date
    Nov 2005
    Posts
    435
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ^_^ glad ya got it working. always (usually) something simple


Bookmarks

Posting Permissions

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