SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Aug 2004
    Location
    UK
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problems with an update query

    Hello people.

    I'm having problems with the 'edit' page of my simple news system.

    Here is the code
    PHP Code:
    // check if an article has been edited in the previous page

    if (isset($_POST['editarticle'])) {

    // complete edit process

    $TABLE $_POST['TABLE'];
    $ID $_POST['ID'];
    $TITLE $_POST['TITLE'];
    $CONTENT $_POST['CONTENT'];
    $sql_insert_article "UPDATE $TABLE SET DATE = '$DATE', TITLE = '$TITLE', CONTENT = '$CONTENT' WHERE ID='$ID'";
                           
    if (@
    mysql_query($sql_insert_article)) {
      echo(
    "Editing succesful $ID $TABLE");
      } else {
      echo(
    "Editing was unsuccesful. " mysql_error());
    }

    } else {

    // show form to add article with ID=$AID 
    Now, I get the right data to be edited in the form, and when I click submit I'm told that editing is succesful. However, the changes are not made in the database.

    I've added $ID and $TABLE into the echo command of a succesful edit and it's interesting to note that only $TABLE prints anything. So I think there's a missing link in the chain in the above code ^^^.


    Thanks for your help in advance.

    Sion

  2. #2
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have a column named DATE. DATE is a reserved word in MySQL. this might be what your update is stuck on. I'd say to rename your column in your database, but if you don't then try your query as `DATE` using the backslashes around it.

  3. #3
    SitePoint Member
    Join Date
    Aug 2004
    Location
    UK
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK Thanks. It ended up being a typo in the form


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
  •