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 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. 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. 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
Archived
This topic is now archived and is closed to further replies.