Forums

This topic is locked

problems inserting date into DB [php_mysql]

Posted 21 Jan 2004 17:35:34
1
has voted
21 Jan 2004 17:35:34 Paul Brown posted:
Hey

FYI I'm using the php_server model and trying to insert a simple record into a database. Everything is kewl except I dont know how to get the current date inserted along with the record.

Here is my form...
<img src="www.teknek.com/sc.gif" border=0>
Obviously I want the current date to be insert so dont want the user to see this....

DMX2004 generates the following code to insert the other form items into the DB...
&lt;code&gt;
if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1") {
$insertSQL = sprintf("INSERT INTO news (headline, body, keywords) VALUES (%s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['headline'], "text",
GetSQLValueString($HTTP_POST_VARS['body'], "text",
GetSQLValueString($HTTP_POST_VARS['keywords'], "text",
&lt;/code&gt;

What do I add to this "insert" code, so that the current date is inserted into the DB. The DB already has a field 'date_posted' of type 'date'.

Thanks in advance for your help on this <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

Cheers

Paul Brown ( )

Replies

Replied 26 Jan 2004 23:52:30
26 Jan 2004 23:52:30 DJ Lewis replied:
Change the field type from 'date' to 'timestamp' and you should be good to go.

Reply to this topic