Inserting time into MySQL.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mightywayne
Forum Contributor
Posts: 237
Joined: Sat Dec 09, 2006 6:46 am

Inserting time into MySQL.

Post 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?
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Re: Inserting time into MySQL.

Post 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.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Inserting time into MySQL.

Post 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.
Mightywayne
Forum Contributor
Posts: 237
Joined: Sat Dec 09, 2006 6:46 am

Re: Inserting time into MySQL.

Post by Mightywayne »

Got it, thanks folks.
Post Reply