SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Could not update the entry because...

    I am trying to update a media release with this mysql code:
    Code MySQL:
    $update = "UDPATE `mediareleases` SET title = '$title', text = '$text', date = '$date' WHERE id = '$id'";
    . When I do it displays the following error:
    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 'UDPATE `mediareleases` SET title = 'Youth participation the key to strong commun' at line 1. The query was UDPATE `mediareleases` SET title = 'Media release title goes here', text = 'Media release text goes here.
    ', date = 'Friday, February 22, 2008' WHERE id = '44'. Could it be the date field? The date type is date. I did a select query to display that date with date_format. Can someone please help me get past that error? Thanks in advance.

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Are $title and $text being escaped before put in the query?

  3. #3
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes.

  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The date field being invalid shouldn't cause the query to fail, just the wrong date to be inserted, so that isn't it. Output the entire actual query that failed. Does it look right to you? Does it run when you execute it against MySQL directly (through the MySQL console or phpMyAdmin)?

    Also try putting backticks around `text` and `date`, as they are reserved words you shouldn't be using as column names.

  5. #5
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,247
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    i am going to take a wild guess and say that maybe UDPATE is the wrong command keyword

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  6. #6
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No update is the right command that I should be using, r937. As I want to edit this media release.

  7. #7
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have changed some things in my database. However I am still getting the error. My database structure looks like this:
    id // the primary key auto-incremented number
    title // type: text
    body // type: text
    date_entered // date

    Now it is going one further and having a problem with the body. Anyway here is the error message again in a different row:
    Could not update the entry because: 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 'UDPATE `mediareleases` SET title = 'Baradine\'s doctor crisis', body = 'Over eig' at line 1. The query was UDPATE `mediareleases` SET title = 'Baradine\'s doctor crisis', body = 'Over eig...', date_entered = 'Friday, April 4, 2008' WHERE id = '57'. Here is the update thing again:
    Code MySQL:
    $update = "UDPATE `mediareleases` SET title = '$title', body = '$body', date_entered = '$date_entered' WHERE id = '$id'";

  8. #8
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,247
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    okay, i hinted at it, and nobody saw it, so i will come right out and tell you

    you spelled it wrong

    it's UPDATE, not UDPATE

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  9. #9
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    i noticed.
    Check out our new Industry News forum!
    Keep up-to-date with the latest SP news in the Community Crier

    I edit the SitePoint Podcast


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
  •