Results 1 to 7 of 7
  1. #1

    Default PHP Gurus please help...


    I found hard to distinguish what is the problem with this query:

    Code:
    $today = gmdate('2007-06-27 01:42:28'); //this is hardcoded based from the result $expire = 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; 
    
    $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:

    Code:
    $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);

    NOTE: The only difference is there gmdate parameters. Others are the same.

    Can you explain to me...

  2. #2

    Default Re: PHP Gurus please help...

    what was the error or the incorrect output?


  3. #3

    Default Re: PHP Gurus please help...

    Well, the second one, output 0 always, while the first one output the correct answer. But in this case, this should be the same, because I am just hardcoded the result of gmdate('Y-m-d H:i:s') to the first one. Is it a bug with PHP and MySQL?. Please advised.

  4. #4

    Default Re: PHP Gurus please help...

    - what is the situation?
    - what are you trying to do?.
    - what is the problem?.


    http://www.php.net/manual/en/function.gmdate.php

  5. #5

    Default Re: PHP Gurus please help...

    Quote Originally Posted by rusbel
    Well, the second one, output 0 always, while the first one output the correct answer. But in this case, this should be the same, because I am just hardcoded the result of gmdate('Y-m-d H:i:s') to the first one. Is it a bug with PHP and MySQL?. Please advised.
    have tried to "echo" your query?

    do this first and see if your "$today" is in a format acceptable to MySQL.


    Code:
    $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";
    
    echo $sql . "<br/>";
    
    //$result1 = mysql_query($sql);
    //$numofrows1 = mysql_num_rows($result1);

  6. #6

    Default Re: PHP Gurus please help...

    ^^ Yeah, it would be helpful if you echoed both queries to see the difference. Post the echoed q's here.


  7. #7

    Default Re: PHP Gurus please help...

    please tell us what is the datatype of dt_detection.

  8.    Advertisement

Similar Threads

 
  1. please help me how to connect my two computer for myDSL
    By rayfloydcabrera in forum Computer Hardware
    Replies: 13
    Last Post: 11-10-2013, 08:40 PM
  2. Replies: 2
    Last Post: 11-06-2006, 01:29 PM
  3. R/C Enthusiasts.. Please Help
    By vipvip68 in forum Gizmos & Gadgets (Old)
    Replies: 0
    Last Post: 09-17-2005, 02:46 PM
  4. Please Help me!
    By SeventhSlave in forum Music & Radio
    Replies: 13
    Last Post: 09-05-2005, 01:12 AM
  5. Please HELP!
    By oliver_g0110 in forum Software & Games (Old)
    Replies: 4
    Last Post: 08-26-2005, 09:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top