There's no date sample.



  • Good time! I know there's a lot of similar questions here, and I've looked at them, but I haven't found a way to do it. In the commentaries on sensitive questions asked a question, but it wasn't possible to deal with the nature of that.

    $datenow = date("Y-m-d");
        $tmpact = mysql_query("SELECT * FROM actions WHERE fdate <= '$datenow' AND tohda <= '$datenow'");   
    

    where the fields fdate and tohda are in the base of the line with such dates:

    fdate - 2016-11-12 and 2016-09-02 and tohda - 2017-08-14 and 2018-08-01 respectively

    but the request returns 0 lines, while if I clean up the full WHERE conditions just make a sample, all the requests go through, the BD field on the treads (fdate and tohda) has the DATE type. I also tried STR_TO_DATE - there's no ephect. Please help me, maybe I just don't see any obvious things. It doesn't even work like that when it's direct.

    $tmpact = mysql_query("SELECT * FROM actions WHERE fdate !"



  • Learn to cultivate SQL.
    For starters, write like that.

    $datenow = date("Y-m-d");
    $sql = "SELECT * FROM actions WHERE fdate <= '$datenow' AND tohda <= '$datenow'";
    die($sql);
    

    And we're looking at the request, whether he's okay. If so, let's go to the console of mysql (or, for God's sake, chapemaidmin) and start a request there.

    If there's a line in it, we'll check which OBD we're connected to.
    If we don't find it, we'll check our fantasies about what data are actually recorded in the OBD system, for example:

    SELECT fdate, '$datenow', fdate <= '$datenow' as result FROM actions 
    

    And we'll see what happens.

    It should be noted separately that PDO and players should be used instead of mysql_query blasphemy and the tagging of variables directly into the request.

    $stmt = $pdo->prepare("SELECT * FROM actions WHERE fdate <= ? AND tohda <= ?");
    $stmt->execute([$datenow,$datenow]);
    $data = $stmt->fetchAll();
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2