zed420 Posted August 22, 2009 Share Posted August 22, 2009 Hi All Can someone please tell me what am I doing wrong in this query??? Its not giving me anything? total blank, there is diffinatley data in this table on different dates. Many thanks Zed $query = "SELECT * FROM booking WHERE request_date = '$request_date'"; Full code $day = $_GET['day']; $cMonth = $_GET['cMonth']; $cYear = $_GET['cYear']; $today = time(); $request_date = mktime(0,0,0,$cMonth,$day+1,$cYear)-1; //add 1 day subtract 1 second if($today > $request_date) { echo "<font color=red>Error, Post date for Booking any lessons. Please choose the avialable date from tomorrow. </font>"; // post date }else{ .....(I took some code out from here) $query = "SELECT * FROM booking WHERE request_date = '$request_date'"; $result = mysql_query($query)or die(mysql_error()); while ($row = mysql_fetch_array($result)) { extract($row); echo " ".$row['request_date']." ".$row['s_time']." ".$row['e_time']." "; } Quote Link to comment https://forums.phpfreaks.com/topic/171453-solved-query-not-working/ Share on other sites More sharing options...
AviNahum Posted August 22, 2009 Share Posted August 22, 2009 try this: $query = "SELECT * FROM booking WHERE request_date = '".$request_date."'"; Quote Link to comment https://forums.phpfreaks.com/topic/171453-solved-query-not-working/#findComment-904146 Share on other sites More sharing options...
zed420 Posted August 22, 2009 Author Share Posted August 22, 2009 Thanks for your reply but that didn't work, there are no errors just its not fetching the records for Clicked date. Zed Quote Link to comment https://forums.phpfreaks.com/topic/171453-solved-query-not-working/#findComment-904151 Share on other sites More sharing options...
mellis95 Posted August 22, 2009 Share Posted August 22, 2009 What is the output of die($query)? $query = "SELECT * FROM booking WHERE request_date = '$request_date'"; die($query); Quote Link to comment https://forums.phpfreaks.com/topic/171453-solved-query-not-working/#findComment-904153 Share on other sites More sharing options...
zed420 Posted August 22, 2009 Author Share Posted August 22, 2009 this is what got SELECT * FROM booking WHERE request_date = '1251586799' Quote Link to comment https://forums.phpfreaks.com/topic/171453-solved-query-not-working/#findComment-904154 Share on other sites More sharing options...
mellis95 Posted August 22, 2009 Share Posted August 22, 2009 So it looks like your variable $request_date has a value of 1251586799. The query is working. I normally store my dates in the 0000-00-00 format and don't know alot about other formats for storing them, but that is a strange looking value to me. There may be an issue with how your variable is created here: $request_date = mktime(0,0,0,$cMonth,$day+1,$cYear)-1; //add 1 day subtract 1 second I am not expert on date/time, but that is where I would look. Quote Link to comment https://forums.phpfreaks.com/topic/171453-solved-query-not-working/#findComment-904155 Share on other sites More sharing options...
kickstart Posted August 22, 2009 Share Posted August 22, 2009 Hi Adding a day and subtracting a second would seem to give you a rather precise time stamp to find one that is exactly the same. Do you definatly have a record with a timestamp of 1251586799 (ie 2009-08-29 23:59:59)? All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/171453-solved-query-not-working/#findComment-904159 Share on other sites More sharing options...
zed420 Posted August 22, 2009 Author Share Posted August 22, 2009 Thank you all manage to sort it. Thanks Zed Quote Link to comment https://forums.phpfreaks.com/topic/171453-solved-query-not-working/#findComment-904163 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.