inserting current date and time

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

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

GetSQLValueString(current_date(), "date")

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

any ideas?



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",
                        GetSQLValueString($_POST['title'], "text"),
                        GetSQLValueString($_POST['shortdesc'], "text"),
                        GetSQLValueString($_POST['desc'], "text"),
                        GetSQLValueString($_POST['version'], "text"),
                        GetSQLValueString($_POST['minreqs'], "text"),
                        GetSQLValueString($_POST['wareid'], "int"),
                        GetSQLValueString($_POST['catid'], "int"),
                        GetSQLValueString($_POST['hpage'], "text"),
                        GetSQLValueString($_POST['dllink'], "text"),
                        GetSQLValueString($_POST['dlsize'], "text"),
                        GetSQLValueString($_POST['liveyn'], "text"),
                        GetSQLValueString($_POST['triallength'], "text"),
                        GetSQLValueString($_POST['price'], "double"),
                        GetSQLValueString($_POST['keywords'], "text"),
                        GetSQLValueString($_POST['submitdate'], "date"),
                        GetSQLValueString($_POST['submittime'], "date"),
// falls over here
GetSQLValueString(current_date(), "date"),
                        GetSQLValueString(current_time(), "date"),
                        //GetSQLValueString($_POST['livedate'], "date"),
                        //GetSQLValueString($_POST['livetime'], "date"),
                        GetSQLValueString($_POST['swid'], "int"));

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_TIMESTAMP. Therefore when an entry is
inserted or updated, I do not
have to reference this field in my code. It is automatically updated via

good luck

Site Timeline