jeff5656 Posted April 7, 2011 Share Posted April 7, 2011 I have the " or the ' all wrong. Can someone tell me how to do the quoation marks correctly so I dont get a syntax error: as can be seen, the date 10/5/14 is not a variable but I want to convert it to a format that can go into a DATE field. $query = "update table set expir_date = date("Y-m-d", 10/5/14) where id = '$id' "; Quote Link to comment https://forums.phpfreaks.com/topic/233000-quotation-nightmare/ Share on other sites More sharing options...
Maq Posted April 7, 2011 Share Posted April 7, 2011 It's easiest if you break out of the string to use the date() function. I also added single quotes around the date value: $query = "update table set expir_date = '" . date("Y-m-d", "10/5/14") . "' where id = '$id' "; Quote Link to comment https://forums.phpfreaks.com/topic/233000-quotation-nightmare/#findComment-1198327 Share on other sites More sharing options...
jeff5656 Posted April 7, 2011 Author Share Posted April 7, 2011 Wait, don't I need strtotime? I got 0000-00-00 when I did that. Where would the quotes go: like this? $query = "update table set expir_date = '" . date("Y-m-d", strtotime("10/5/14")) . "' where id = '$id' "; Quote Link to comment https://forums.phpfreaks.com/topic/233000-quotation-nightmare/#findComment-1198360 Share on other sites More sharing options...
Maq Posted April 7, 2011 Share Posted April 7, 2011 Wait, don't I need strtotime? I got 0000-00-00 when I did that. Where would the quotes go: like this? $query = "update table set expir_date = '" . date("Y-m-d", strtotime("10/5/14")) . "' where id = '$id' "; Yes sorry, like that. Echo out $query to see exactly what the string looks like, it will give you a better idea. Quote Link to comment https://forums.phpfreaks.com/topic/233000-quotation-nightmare/#findComment-1198362 Share on other sites More sharing options...
jeff5656 Posted April 7, 2011 Author Share Posted April 7, 2011 Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/233000-quotation-nightmare/#findComment-1198370 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.