tchick Posted April 20, 2011 Share Posted April 20, 2011 Hi All, I am trying to pull a record from my table using the date of birth column (which is a date column) like so.. $birthday = ('1936-08-21'); $query = "Select * from my_table where dob = $birthday"; $result = mysql_query($query); while ($row = mysql_fetch_array($result)){ echo "Name is - " .$row['name']; } I know there is a record in the table with a date of birth(dob) value of 1936-08-21 but it does not return any records ? thanks for looking, Tony Quote Link to comment https://forums.phpfreaks.com/topic/234251-selecting-date-from-table-problem/ Share on other sites More sharing options...
Muddy_Funster Posted April 20, 2011 Share Posted April 20, 2011 $query = "Select name from my_table where dob = '$birthday'"; should do it, dates need to be wraped in single quotes within the sql. Quote Link to comment https://forums.phpfreaks.com/topic/234251-selecting-date-from-table-problem/#findComment-1203977 Share on other sites More sharing options...
tchick Posted April 20, 2011 Author Share Posted April 20, 2011 Thanks Muddy_Funster, that sorted it. Quote Link to comment https://forums.phpfreaks.com/topic/234251-selecting-date-from-table-problem/#findComment-1204046 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.