Custom module INSERT, dates always show up as 0000-00-00...
Posted: Sat Feb 24, 2007 12:11 am
So I'm using HitCounter as a guide to developing a "referral" module of sorts, to track linkbacks from other places. I have everything working splendidly, except my date field (MySQL 4.1.21-standard on Linux) always contains "0000-00-00 00:00:00"
As I said, I'm "inspiring" myself from HitCounter, so this is the relevant code:
When I test this, I get the following output on the page:
and the record is created correctly, except date always contains 0000-00-00 00:00:00. I'm not sure where to go from here, and I must admit I haven't verified that HitCounter inserts a proper date. Any ideas?
As I said, I'm "inspiring" myself from HitCounter, so this is the relevant code:
Code: Select all
$ip = getenv("REMOTE_ADDR");
//log the hit as a referral
$newid = $db->GenID( cms_db_prefix()."module_referrals_seq");
$agent = $_SERVER["HTTP_USER_AGENT"];
$referrer = "none";
if( isset($HTTP_REFERER))
$referrer=$HTTP_REFERER;
$tstamp = trim($db->DBTimeStamp(time()));
$q = "INSERT INTO ".cms_db_prefix()."module_referrals
(referral_id, referral_cd, source_ip, url, date, user_agent)
VALUES (?,?,?,?,?,?)";
$dbresult = $db->Execute( $q, array( $newid, $code, $ip, $referrer, $tstamp, $agent));
//some error checks omitted for brevity
echo "<!-- Referral added for $code, $ip, $tstamp -->";
and the record is created correctly, except date always contains 0000-00-00 00:00:00. I'm not sure where to go from here, and I must admit I haven't verified that HitCounter inserts a proper date. Any ideas?