timmah1 Posted December 18, 2008 Share Posted December 18, 2008 What is the right way to write this $time = date("Y-m-d H:i:s"); $sql1 = "SELECT * FROM specials WHERE sport = 'ncaab' AND date("Y-m-d H:i:s", strtotime($time)) BETWEEN 'start' AND 'end'"; I get the message that the Query was empty Thanks in advance Link to comment https://forums.phpfreaks.com/topic/137463-correct-query/ Share on other sites More sharing options...
timmah1 Posted December 18, 2008 Author Share Posted December 18, 2008 Sorry, this code $sql1 = 'SELECT * FROM specials WHERE sport = "ncaab" AND ".date('Y-m-d H:i:s')." BETWEEN "start" AND "end"'; mysql_query($sql) or die("Sorry, there was a problem creating the specials ".mysql_error()); Link to comment https://forums.phpfreaks.com/topic/137463-correct-query/#findComment-718361 Share on other sites More sharing options...
twm Posted December 18, 2008 Share Posted December 18, 2008 what is the date field name? Link to comment https://forums.phpfreaks.com/topic/137463-correct-query/#findComment-718387 Share on other sites More sharing options...
PFMaBiSmAd Posted December 18, 2008 Share Posted December 18, 2008 If that is your actual query string and your query, it is going to be kind of hard to get mysql to perform a query using $sql, when the variable name you have put the query string in to is named $sql1 Link to comment https://forums.phpfreaks.com/topic/137463-correct-query/#findComment-718391 Share on other sites More sharing options...
timmah1 Posted December 18, 2008 Author Share Posted December 18, 2008 That was a typo PFMaBiSmAd I'm trying this, and it isn't working $sql1 = "SELECT * FROM specials WHERE sport = 'ncaab'"; $q1 = mysql_query($sql1); while($a = mysql_fetch_assoc($q1)){ if($time > $a['start'] "AND" $time < $a['end']){ echo $a['name']; } else { echo Try Again; } Link to comment https://forums.phpfreaks.com/topic/137463-correct-query/#findComment-718478 Share on other sites More sharing options...
mmarif4u Posted December 18, 2008 Share Posted December 18, 2008 this: if($time > $a['start'] "AND" $time < $a['end']){ should be: if($time > $a['start'] && $time < $a['end']){ and also make sure that $time holding correct value. Link to comment https://forums.phpfreaks.com/topic/137463-correct-query/#findComment-718482 Share on other sites More sharing options...
timmah1 Posted December 18, 2008 Author Share Posted December 18, 2008 I have time like this $time = date("Y-m-d H:i:s"); Link to comment https://forums.phpfreaks.com/topic/137463-correct-query/#findComment-718484 Share on other sites More sharing options...
mmarif4u Posted December 18, 2008 Share Posted December 18, 2008 Can you post your complete code. Link to comment https://forums.phpfreaks.com/topic/137463-correct-query/#findComment-718487 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.