inserting current date and time

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • toedipper

    #1

    inserting current date and time

    Hello,

    I have the following section of php code which updates a mysql record
    from a form. For the values of livedate and livetime I need to insert
    the current_date() and current_time() respectively.

    When I run the code however it falls over at the line with

    GetSQLValueStri ng(current_date (), "date")

    The error is Fatal error: Call to undefined function: current_date()

    any ideas?

    Thanks,

    td


    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "frmaddsw") ) {
    $updateSQL = sprintf("UPDATE software SET title=%s, shortdesc=%s,
    `desc`=%s, version=%s, minreqs=%s, wareid=%s, catid=%s, hpage=%s,
    dllink=%s, dlsize=%s, liveyn=%s, triallength=%s, price=%s, keywords=%s,
    submitdate=%s, submittime=%s, livedate=%s, livetime=%s WHERE swid=%s",
    GetSQLValueStri ng($_POST['title'], "text"),
    GetSQLValueStri ng($_POST['shortdesc'], "text"),
    GetSQLValueStri ng($_POST['desc'], "text"),
    GetSQLValueStri ng($_POST['version'], "text"),
    GetSQLValueStri ng($_POST['minreqs'], "text"),
    GetSQLValueStri ng($_POST['wareid'], "int"),
    GetSQLValueStri ng($_POST['catid'], "int"),
    GetSQLValueStri ng($_POST['hpage'], "text"),
    GetSQLValueStri ng($_POST['dllink'], "text"),
    GetSQLValueStri ng($_POST['dlsize'], "text"),
    GetSQLValueStri ng($_POST['liveyn'], "text"),
    GetSQLValueStri ng($_POST['triallength'], "text"),
    GetSQLValueStri ng($_POST['price'], "double"),
    GetSQLValueStri ng($_POST['keywords'], "text"),
    GetSQLValueStri ng($_POST['submitdate'], "date"),
    GetSQLValueStri ng($_POST['submittime'], "date"),
    // falls over here
    GetSQLValueStri ng(current_date (), "date"),
    GetSQLValueStri ng(current_time (), "date"),
    //GetSQLValueStri ng($_POST['livedate'], "date"),
    //GetSQLValueStri ng($_POST['livetime'], "date"),
    GetSQLValueStri ng($_POST['swid'], "int"));
  • Sam

    #2
    Re: inserting current date and time

    I used the MySQL Administrator and created a table with a column called
    import_date of type timestamp.
    The default value is CURRENT_TIMESTA MP. Therefore when an entry is
    inserted or updated, I do not
    have to reference this field in my code. It is automatically updated via
    mysql.

    good luck

    Comment

    Working...