neo_phyte Posted June 27, 2007 Share Posted June 27, 2007 I found hard to distinguish what is the problem with this query: $today = gmdate('2007-06-27 01:42:28'); $expire = gmdate('2007-06-27 23:59:59'); $sql = "SELECT avatar_name FROM $table where avatar_group = 'Avatrian Central' AND dt_detection > '$today' AND dt_detection < '$expire' group by avatar_name"; $result1 = mysql_query($sql); $numofrows1 = mysql_num_rows($result1); it returns a correct OUPUT but when I changed something like this: $today = gmdate('Y-m-d H:i:s'); $expire = gmdate('Y-m-d 23:59:59'); $sql = "SELECT avatar_name FROM $table where avatar_group = 'Avatrian Central' AND dt_detection > '$today' AND dt_detection < '$expire' group by avatar_name"; $result1 = mysql_query($sql); $numofrows1 = mysql_num_rows($result1); it seems that PHP stops working, it gives no output. Please advised. Can you explain to me... Quote Link to comment https://forums.phpfreaks.com/topic/57353-what-is-the-difference-of-this-query/ Share on other sites More sharing options...
AndyB Posted June 27, 2007 Share Posted June 27, 2007 As a general debug tip, after you have defined the querystring $sql, add a line to echo $sql. At least then you know what the actual query was. That often points the way toward a solution. Quote Link to comment https://forums.phpfreaks.com/topic/57353-what-is-the-difference-of-this-query/#findComment-283612 Share on other sites More sharing options...
neo_phyte Posted June 27, 2007 Author Share Posted June 27, 2007 Sorry my subject is not emphasize more. No, the query is just the same with the first one... The difference is: $today = gmdate('2007-06-27 02:01:16'); //this is hardcoded based from the result $today = gmdate('Y-m-d H:i:s'); echo $today; $expire = gmdate('2007-06-27 23:59:59'); //this is hardcoded based from the result $expire = gmdate('Y-m-d 23:59:59'); echo $expire; to this: $today = gmdate('Y-m-d H:i:s'); $expire = gmdate('Y-m-d 23:59:59'); Quote Link to comment https://forums.phpfreaks.com/topic/57353-what-is-the-difference-of-this-query/#findComment-283624 Share on other sites More sharing options...
AndyB Posted June 27, 2007 Share Posted June 27, 2007 If one query works and the other makes the script stop working then they can't possibly be the same. While you might think they're the same, or expect they're the same, you will only know what the query string is if you echo it. $sql = "SELECT ....."; // your query echo $sql; // displays the query Quote Link to comment https://forums.phpfreaks.com/topic/57353-what-is-the-difference-of-this-query/#findComment-283676 Share on other sites More sharing options...
neo_phyte Posted June 27, 2007 Author Share Posted June 27, 2007 Yap, i am really sure that they are the same query. What i am doing is just changing the parameters of gmdate function. But it seems that they have different output. Quote Link to comment https://forums.phpfreaks.com/topic/57353-what-is-the-difference-of-this-query/#findComment-283771 Share on other sites More sharing options...
bubblegum.anarchy Posted June 27, 2007 Share Posted June 27, 2007 fuzzy wuzzy wuz a rabbit. Quote Link to comment https://forums.phpfreaks.com/topic/57353-what-is-the-difference-of-this-query/#findComment-283794 Share on other sites More sharing options...
neo_phyte Posted June 27, 2007 Author Share Posted June 27, 2007 To prove this: This link is the manual input of date and time. This is manually based on the output that I mentioned in my code. http://www.bacsafra.com/secondlifestuff/testing1.php This link is using the Y-m-d H:i:s http://www.bacsafra.com/secondlifestuff/testing1.php Quote Link to comment https://forums.phpfreaks.com/topic/57353-what-is-the-difference-of-this-query/#findComment-283806 Share on other sites More sharing options...
neo_phyte Posted June 27, 2007 Author Share Posted June 27, 2007 sorry some modifications: This link is using the Y-m-d H:i:s http://www.bacsafra.com/secondlifestuff/testing.php Quote Link to comment https://forums.phpfreaks.com/topic/57353-what-is-the-difference-of-this-query/#findComment-283814 Share on other sites More sharing options...
neo_phyte Posted June 27, 2007 Author Share Posted June 27, 2007 MODIFICATIONS. Sorry To prove this: This link is the manual input of date and time. This is manually based on the output that I mentioned in my code. http://www.bacsafra.com/secondlifestuff/testing1.php This link is using the Y-m-d H:i:s http://www.bacsafra.com/secondlifestuff/testing.php Quote Link to comment https://forums.phpfreaks.com/topic/57353-what-is-the-difference-of-this-query/#findComment-283815 Share on other sites More sharing options...
AndyB Posted June 27, 2007 Share Posted June 27, 2007 Here is the output from the 'identical' queries produced by those links: SELECT avatar_name FROM tbl_avatar where avatar_group = 'Avatrian Central' AND dt_detection > '2007-06-27 06:52:26' AND dt_detection < '2007-06-27 23:59:59' group by avatar_name SELECT avatar_name FROM tbl_avatar where avatar_group = 'Avatrian Central' AND dt_detection > '2007-06-27 11:35:16' AND dt_detection < '2007-06-27 23:59:59' group by avatar_name As we can now all see, these are not identical queries - they have different starting times. You need to look a little deeper into exactly how those times are produced. Quote Link to comment https://forums.phpfreaks.com/topic/57353-what-is-the-difference-of-this-query/#findComment-283932 Share on other sites More sharing options...
AndyB Posted June 30, 2007 Share Posted June 30, 2007 I assume this is either solved or abandoned. Quote Link to comment https://forums.phpfreaks.com/topic/57353-what-is-the-difference-of-this-query/#findComment-286385 Share on other sites More sharing options...
rcorlew Posted June 30, 2007 Share Posted June 30, 2007 Try changing your code to this and see what happens: $today = date('Y-m-d H:i:s'); $expire = date('Y-m-d' '23:59:59'); Quote Link to comment https://forums.phpfreaks.com/topic/57353-what-is-the-difference-of-this-query/#findComment-286598 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.