Re: need to compare date between variable and mysql stored date
Posted by:
ibakebread
Date: August 05, 2005 07:54AM
Thanks for your suggestion Jay. I'm still having a problem though. I now get this error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home...../news.php on line 16
I tested the query itself in phpAdmin and changed the $temp_date variable to a specific date (since the mySQL monitor wouldn't know what the variable is). When I do that, I get the result I want.
I also tried printing out the $temp_date variable and it produces the correct result. So it seems that there's a problem with the $temp_date variable in the query. Any ideas? Again, here's the query, with you added code:
$temp_date = $_GET['news_item'];
$time_string = substr($temp_date,0,4) . '-' . substr($temp_date, 4,2) . '-' . substr($temp_date, 6,2) . ' ' . substr($temp_date, 9,2) . ':' . substr($temp_date, 11,2) . ':' . substr($temp_date, 13,2);
$temp_date = date('Y-m-d H:i:s', strtotime($time_string));
$query = "SELECT title,author,type,text,link FROM news WHERE date =" . $temp_date . "LIMIT 1";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
...
Thanks for your help