PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Im using this code to search my database for a particular date, this code worked fine when I was searching text i.e, names but when I search for dates it doesnt produce results even if I put in the exact copy of a date which I know exists.
Can anyone see where I am going wrong or give me any advice or another way to search dates in php.
foreach($HTTP_POST_VARS as $varname => $value)
$formVarsї$varname]=$value;
// the query used to search the DB
$query = "SELECT *, DATE_FORMAT(`dateoflastcontact`, '%d/%m/%y')
AS `dateoflastcontact`, FROM `people` WHERE 'dateoflastcontact' LIKE '$formVarsїdateoflastcontact]%'";
$result = mysql_query($query);
you're using single quotes instead of backticks in the WHERE clause's dateoflastcontact reference.. this may ask MySQL to check the string 'dateoflastcontact' instead of the column.. Not sure though.
you may need to use a date/time function on one or both of the values like TO_DAYS() if you want to match the date only, although if the value you are searching for is in the wrong format, then I don't know for sure.. as I haven't tested it personally.