Jump to content

[SOLVED] current date as value


BrianM

Recommended Posts

No no no. Echo is used to display your string on the screen. You are just processing information here.

 

<?php
mysql_query("INSERT INTO ".$_POST['projectnumber']." (Date) VALUES ('" . date("m-d-y") . "')");
?>

 

You need to wrap your date() parameter with quotes aswell. I'm not sure if you can use Date as a fieldname. But if that works, then I guess you can.

Storing a date as mm-dd-yy in a database will result in the most painful experience for you and if your Date field happens to be a DATE data type, will result in invalid data (you will probably get 0000-00-00 in the database.)

 

Once you switch to use a standard DATE format, mysql has a CURDATE() function that returns the current date directly in the query statement.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.