For the life of me I can't get the current date to insert into my table. I would like a "submitted date" to be stored upon the creation of the record. I've tried countless different ways to achieve this and every time I get no results in the table, just the default 0000-00-00 (it's set to date). Being completely new to this I'm positive I'm doing some completely wrong, I just can't figure out what.

// Insert fields into XINFO 
	$sql = "INSERT INTO xinfo SET
	 
date_submit='$dsub',    //<--  set to $dsub = 'CURDATE()';
first_name='$fn',
last_name='$ln',
city='$city',
state_province='$state',
country='$cntry',
other_country='$ocntry',
dob='$dob',
email='$em'";

// execute query
    $result = mysql_query($sql);

I think you'll find that the example at this page will shed light on the problem.

Just from a glance, and not being set up to test it, I'd say to change date_submit='$dsub' to date_submit=CURDATE() .

Thanks jcacquiescent27,
Perhaps I simply needed to slow down a bit and walk myself through it. Oddly enough CUREDATE() works if I change my syntax to

// Insert fields into XINFO 
	 $sql = "INSERT INTO xinfo (date_submit) VALUE (CURDATE())";

Instead of the way I had it

date_submit = CURDATE();

would not work

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.