Page 1 of 1

Inserting time into MySQL.

Posted: Mon Feb 04, 2008 3:58 pm
by Mightywayne

Code: Select all

 
$time = date('M dS - h:i A');
      mysql_query("INSERT INTO guildnews (ID, guild, news, time) VALUES ('', '$id', '$wholename donated $donated Bux to the guild.', '$time')");
 
That's my code I use to insert into the database. I tried setting time to "time" and "timestamp" in the DB and nothing. My friend once told me it was supposed to be time, so that's why I think I'm doing something wrong in the first place.

And $time itself works correctly, Feb 04th - 04:28 PM!

Anyway, what's wrong?

Re: Inserting time into MySQL.

Posted: Mon Feb 04, 2008 4:08 pm
by Oren
Feb 04th - 04:28 PM does not make sense.
Please tell us what type "time" is?
I assume it is of type time, so please pass it something like 23:44:01.

Re: Inserting time into MySQL.

Posted: Mon Feb 04, 2008 4:09 pm
by califdon
The list within the first parentheses are the field names, so if that's what you're talking about, nobody (not even your friend) can tell you what name the field has unless you do a describe guildnews at the command line or use phpmyadmin to look at your table definition.

Re: Inserting time into MySQL.

Posted: Mon Feb 04, 2008 4:18 pm
by Mightywayne
Got it, thanks folks.