robert_gsfame Posted September 4, 2009 Share Posted September 4, 2009 Small things, but really difficult to find the error........ i have my column inside table --> date(datetime) the problem is that once i try to insert the date using: $date = date("YYYY-mm-dd H:i:s"); $query = "INSERT INTO xxxxxx(date)VALUES('$date'); $results = mysql_query('$query'); why does the date column still (0000-00-00 00:00:00) , although the other columns have been inserted which means i don't get any problems with the connection Link to comment https://forums.phpfreaks.com/topic/173122-solved-insert-date-and-time-into-mysql/ Share on other sites More sharing options...
rhodesa Posted September 4, 2009 Share Posted September 4, 2009 don't use Date as a column name...it's a reserved word in MySQL Link to comment https://forums.phpfreaks.com/topic/173122-solved-insert-date-and-time-into-mysql/#findComment-912486 Share on other sites More sharing options...
robert_gsfame Posted September 4, 2009 Author Share Posted September 4, 2009 okay i've changed it but still give me the same result.. Do i have to change the format of the date?? it's easier to have it in VARCHAR format, but yet it will create new problem as i want to sort the records based on datetime Link to comment https://forums.phpfreaks.com/topic/173122-solved-insert-date-and-time-into-mysql/#findComment-912489 Share on other sites More sharing options...
PFMaBiSmAd Posted September 4, 2009 Share Posted September 4, 2009 date("YYYY-mm-dd H:i:s") means - 2009200920092009-0909-0404 09:57:00 (depending on where you are at.) you want date("Y-m-d H:i:s") Link to comment https://forums.phpfreaks.com/topic/173122-solved-insert-date-and-time-into-mysql/#findComment-912493 Share on other sites More sharing options...
robert_gsfame Posted September 4, 2009 Author Share Posted September 4, 2009 Thx for your help...Finally, i've found out what makes this error! Wrong parameters name Link to comment https://forums.phpfreaks.com/topic/173122-solved-insert-date-and-time-into-mysql/#findComment-912497 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.