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 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2007
    Location
    Canada
    Posts
    49
    Thanks
    1
    Thanked 1 Time in 1 Post

    Update datetime error

    Drawing a blank as to what I am doing wrong. I'm trying to update a DATETIME field with the following:

    Code:
    $query .= ", commission=" . $_post['commission'] . ", date_modified='" . date("Y-m-d H:i:s") . "', modified_by='" . $_SESSION['user_name'] . "'";
    $query .= " WHERE part_id='" . $_POST['part_id'] . "'";
    I keep getting the following error:
    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 ' date_modified='2007-11-18 22:34:19', modified_by='Alan' WHERE part_id='0007~'' at line 1

    I know I'm staring at the problem... but where?

    Thanks
    Of all the things I've lost in my life time, my mind is the one I miss the most!

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    It looks like you're missing quotes around the commision value. Also, use the MySQL function NOW() for the datetime if you want to set it to the current time. If you still get an error post the entire query.
    Last edited by Inigoesdr; 11-19-2007 at 05:06 AM.

  • #3
    New Coder
    Join Date
    Nov 2007
    Posts
    12
    Thanks
    0
    Thanked 1 Time in 1 Post
    i just tried to make
    echo $query;
    this way I can see if there is anything not normal

    It looks like you have no quotation marks around
    commission=value ( should be: commission='value' )

    also not $_post, but use$_POST

    Try this:
    PHP Code:
    $query .= ", commission='" $_POST['commission'] . "', date_modified='" date("Y-m-d H:i:s")
     . 
    "', modified_by='" $_SESSION['user_name'] . "'";
    $query .= " WHERE part_id='" $_POST['part_id'] . "'";
    // debug
    echo $query;
    exit(); 
    Last edited by phpBuddy; 11-19-2007 at 07:52 AM.
    echo "PHP 5.2.5";
    exit ( "Script End" );

  • #4
    New Coder
    Join Date
    Jun 2007
    Location
    Canada
    Posts
    49
    Thanks
    1
    Thanked 1 Time in 1 Post
    Thanks... The commission which is a numeric value was missing.
    Of all the things I've lost in my life time, my mind is the one I miss the most!


  •  

    Posting Permissions

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