PHP/SQL Time Issues...

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

PHP/SQL Time Issues...
  1. Unread #1 - Mar 31, 2009 at 3:14 AM
  2. i am java
    Joined:
    Apr 9, 2008
    Posts:
    231
    Referrals:
    0
    Sythe Gold:
    0

    i am java Active Member

    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?
     
  3. Unread #2 - Mar 31, 2009 at 3:23 PM
  4. Nullware
    Joined:
    Jan 30, 2007
    Posts:
    1,761
    Referrals:
    4
    Sythe Gold:
    0

    Nullware Guru

    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.
     
  5. Unread #3 - Mar 31, 2009 at 6:13 PM
  6. i am java
    Joined:
    Apr 9, 2008
    Posts:
    231
    Referrals:
    0
    Sythe Gold:
    0

    i am java Active Member

    PHP/SQL Time Issues...

    It's not. This topic can be locked. I am getting support at W3schools now.
     
  7. Unread #4 - Mar 31, 2009 at 6:24 PM
  8. hampe-92
    Joined:
    Jul 10, 2008
    Posts:
    328
    Referrals:
    0
    Sythe Gold:
    0

    hampe-92 Forum Addict

    PHP/SQL Time Issues...

    no, I think you can post your solution so others can learn from it...
     
  9. Unread #5 - Mar 31, 2009 at 7:40 PM
  10. i am java
    Joined:
    Apr 9, 2008
    Posts:
    231
    Referrals:
    0
    Sythe Gold:
    0

    i am java Active Member

    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. >

Users viewing this thread
1 guest


 
 
Adblock breaks this site