[SOLVED] MySQL timestamp INSERT successful only some of time

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
voltrader
Forum Contributor
Posts: 223
Joined: Wed Jul 07, 2004 12:44 pm
Location: SF Bay Area

[SOLVED] MySQL timestamp INSERT successful only some of time

Post by voltrader »

- TIMESTAMP column in the table created
- PHP's time() used to get unix timestamp
- I echo out the MySQL statement before doing the INSERT, which shows time() being inserted

Problem I run into is that time() only inserted successfull in db about 50% of the time. Other records still have the default 14 zeros. There are no errors displayed.

Not sure where to look...
Last edited by voltrader on Sun Jan 30, 2005 11:09 pm, edited 1 time in total.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

which is the mysql version you are using?

what is the exact query? as you are generating a unix timestamp, do you use the from_unixtime function?
User avatar
voltrader
Forum Contributor
Posts: 223
Joined: Wed Jul 07, 2004 12:44 pm
Location: SF Bay Area

Post by voltrader »

Thanks for the reply... figured it out: TIMESTAMP automatically timestamps any INSERT. I was writing over the TIMESTAMP by mistake.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

btw, timestamps behaviour differs in versions <4.1 and more recent...
Post Reply