manix Posted August 4, 2011 Share Posted August 4, 2011 Erm I'm trying to insert a date into mysql but I'm failing $date = date(Y-m-d); this is my date variable which I tried to insert but in mysql the date was like 0000-00-00 and I googled my issue ofcourse and what I came up with was strtotime() but this failed as well, so I need help with inserting a date into a DATE mysql field Quote Link to comment Share on other sites More sharing options...
WebStyles Posted August 4, 2011 Share Posted August 4, 2011 missing double quotes: $date = date("Y-m-d"); Quote Link to comment Share on other sites More sharing options...
voip03 Posted August 4, 2011 Share Posted August 4, 2011 If you google it 'php date format' you will get the answer. Quote Link to comment Share on other sites More sharing options...
voip03 Posted August 4, 2011 Share Posted August 4, 2011 some examples http://php.net/manual/en/function.date.php http://www.w3schools.com/PHP/php_date.asp Quote Link to comment Share on other sites More sharing options...
manix Posted August 4, 2011 Author Share Posted August 4, 2011 I am using the function properly, I just made a typo in the rush, I do have double quotes and when I echo the date it is correct, but I can not insert it in the database, and it's not giving me any error it's just not inserting it >.< Quote Link to comment Share on other sites More sharing options...
xyph Posted August 4, 2011 Share Posted August 4, 2011 missing double quotes: $date = date("Y-m-d"); *** Just quotes in general. In this case, single quotes would be a little better, as double quoted strings are parsed, and we don't need parsing in this case Can you give us a dump of the table and the query used? Quote Link to comment Share on other sites More sharing options...
manix Posted August 4, 2011 Author Share Posted August 4, 2011 quotes are not the problem, echo $date; returns 2011-08-04 so it's alright Quote Link to comment Share on other sites More sharing options...
WebStyles Posted August 4, 2011 Share Posted August 4, 2011 well, if the problem are not the missing quotes (I guarantee that was ONE of the problems)... since you only gave us one line of code, how are we supposed to fix the rest ? Quote Link to comment Share on other sites More sharing options...
voip03 Posted August 4, 2011 Share Posted August 4, 2011 Are you trying to insert date into mysql? Then you need NOW (). Quote Link to comment Share on other sites More sharing options...
manix Posted August 4, 2011 Author Share Posted August 4, 2011 God, it works now... I hate it when this happens, I haven't edited any of the code that inserts the date and yet it works now and I never found where the problem was >.< anyways, sorry for wasting your time.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.