0

I have a function like this

function get_visits($date)
{
    global $db;
    $sql = "SELECT * FROM visits WHERE v_date=$date";
    $stmt = $db->prepare($sql);
    $stmt->execute();
    $s = $stmt->fetchAll(PDO::FETCH_OBJ);
    return $s;
}

I call this with this code

$date = '2021/08/08' ;
$visits = get_visits($date);

In SQL I have a column called v_date, that have a date

If we store phrase 1 or any phrase like this in that cell and $date=1; then my code work. Otherwise, it's not.

Phil Dukhov
  • 67,741
  • 15
  • 184
  • 220

0 Answers0