blew Posted February 5, 2011 Share Posted February 5, 2011 guys, im having a problem here thats making me crazy im making a system and i want to insert the current date in the mysql. I have the field called 'data' in the DB, but when i make the code to insert all the other fields, including the 'data', its work perfectly... unless that damn date! $query = "INSERT INTO news (id, titulo, mensagem, data) VALUES (NULL, '$titulo', '$mensagem', 'date(\"d/m/Y\")')"; whats wrong with that? its stores in DB as '0000-00-00'. Link to comment https://forums.phpfreaks.com/topic/226781-how-do-insert-date-into-mysql-db/ Share on other sites More sharing options...
brown2005 Posted February 5, 2011 Share Posted February 5, 2011 date("Y-m-d"); thats how i enter them in mine. Link to comment https://forums.phpfreaks.com/topic/226781-how-do-insert-date-into-mysql-db/#findComment-1170230 Share on other sites More sharing options...
blew Posted February 5, 2011 Author Share Posted February 5, 2011 date("Y-m-d"); thats how i enter them in mine. thats not working Link to comment https://forums.phpfreaks.com/topic/226781-how-do-insert-date-into-mysql-db/#findComment-1170232 Share on other sites More sharing options...
Pikachu2000 Posted February 5, 2011 Share Posted February 5, 2011 Hopefully the data type for the field is DATE or DATETIME as it should be, then you simply use MySQL's NOW() function. Link to comment https://forums.phpfreaks.com/topic/226781-how-do-insert-date-into-mysql-db/#findComment-1170234 Share on other sites More sharing options...
blew Posted February 5, 2011 Author Share Posted February 5, 2011 Hopefully the data type for the field is DATE or DATETIME as it should be, then you simply use MySQL's NOW() function. yep, the field is set as DATE, and i used NOW() , but this is still inserting as 0000-00-00 arrrghhh Link to comment https://forums.phpfreaks.com/topic/226781-how-do-insert-date-into-mysql-db/#findComment-1170239 Share on other sites More sharing options...
blew Posted February 5, 2011 Author Share Posted February 5, 2011 Thank you man, its working now... i just removed the single quotes and its worked! tks everybody its solved!! Link to comment https://forums.phpfreaks.com/topic/226781-how-do-insert-date-into-mysql-db/#findComment-1170242 Share on other sites More sharing options...
Pikachu2000 Posted February 5, 2011 Share Posted February 5, 2011 Post the code around your query string, please . . . Link to comment https://forums.phpfreaks.com/topic/226781-how-do-insert-date-into-mysql-db/#findComment-1170243 Share on other sites More sharing options...
blew Posted February 5, 2011 Author Share Posted February 5, 2011 Post the code around your query string, please . . . its solved ty so much Link to comment https://forums.phpfreaks.com/topic/226781-how-do-insert-date-into-mysql-db/#findComment-1170245 Share on other sites More sharing options...
colap Posted February 5, 2011 Share Posted February 5, 2011 Hopefully the data type for the field is DATE or DATETIME as it should be, then you simply use MySQL's NOW() function. yep, the field is set as DATE, and i used NOW() , but this is still inserting as 0000-00-00 arrrghhh http://colalinux.blogspot.com/2011/02/insert-date-into-mysql-table.html Link to comment https://forums.phpfreaks.com/topic/226781-how-do-insert-date-into-mysql-db/#findComment-1170262 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.