Adblock breaks this site

PHP/SQL Time Issues...

Discussion in 'Web Programming' started by i am java, Mar 31, 2009.

  1. i am java

    i am java Active Member

    Joined:
    Apr 9, 2008
    Posts:
    231
    Referrals:
    0
    Sythe Gold:
    0
    PHP/SQL Time Issues...

    OK, so a friend of mine was bored, so I told him to write me a small, simple script. For some reason, the script doesn't seem to work still. I honestly can't figure it out, and we are both pretty good PHP programmers.

    Code:
    $sql="SELECT * FROM `test` WHERE `testm`-".date("U")."<5 ORDER BY `testm` DESC";
    Now, for some reason, it doesn't just select the times from 5 seconds ago (which is the time I am using to simply test the script ATM), it selects everything in the table.

    Anyone got any ideas?
     
  2. Nullware

    Nullware Guru

    Joined:
    Jan 30, 2007
    Posts:
    1,761
    Referrals:
    4
    Sythe Gold:
    0
    PHP/SQL Time Issues...

    I think it has to do with you using double quotes in the middle of the query when the whole query is also surrounded by double quotes. I'm kind of surprised it works I would think that they need to be escaped but I haven't done much work with SQL.
     
  3. i am java

    i am java Active Member

    Joined:
    Apr 9, 2008
    Posts:
    231
    Referrals:
    0
    Sythe Gold:
    0
    PHP/SQL Time Issues...

    It's not. This topic can be locked. I am getting support at W3schools now.
     
  4. hampe-92

    hampe-92 Forum Addict

    Joined:
    Jul 10, 2008
    Posts:
    328
    Referrals:
    0
    Sythe Gold:
    0
    PHP/SQL Time Issues...

    no, I think you can post your solution so others can learn from it...
     
  5. i am java

    i am java Active Member

    Joined:
    Apr 9, 2008
    Posts:
    231
    Referrals:
    0
    Sythe Gold:
    0
    PHP/SQL Time Issues...

    I had the current time and the time in the DB mixed up, so when I would subtract the current time by the time in the DB, it would give me negative numbers. Thus, when it was selecting the users from the DB, it was selecting everyone because everyone's last activity was in the negatives. (IE, less than 5.)

    The simple solution? I replaced

    with

     
< Centering a CSS <div> Menu | wanting to embed. >


 
 
Adblock breaks this site