I have the following code (php, mysql, pdo):
$stmt = $db->prepare("INSERT INTO agent_temp SET party=?, date = NOW()");
$stmt->execute(array($party));
when run, the party is insert correctly but the date is not inserting as it should (the system date and time at action). I have verified numerous times the field type for date is datetime.
Any ideas?
To give actual data and the results returned:
assume the following:
$party = 'John';
the results return:
party | date
-------------------------------------
John | 0000-00-00 00:00:00
update:
When i run the following code directly within a mysql query browser, the insert works just as it should:
insert into agent_temp set party = 'John', date = NOW();
returning:
party | date
-------------------------------------
John | 2010-12-28 13:15:23
Well, who is ready to kill me? I have no idea what caught it up but unfortunately the issue seemingly was due to an earlier version of the php script from my machine being cached and still running bad data. I refreshed, closed, and emptied my browser and now the script works. My apologies for making everybody's brains melt just a little.
How about:
$stmt = $db->prepare("INSERT INTO agent_temp SET party=?, date = ?");
$stmt->execute(array($_POST['party'], date("Y-m-d H:i:s")));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With