This works
$stmt = $conn->prepare("select username from usernames where session" . "1" . " = :session");
$stmt->bindParam(':session', $session);
$stmt->execute();
But this does not work
$data = "1";
$stmt = $conn->prepare("select username from usernames where session" . ":data" . " = :session");
$stmt->bindParam(':data', $data);
$stmt->bindParam(':session', $session);
$stmt->execute();
I have been trying to figure out why. Can some please help.
the only thing I can think of is my database has session1 as a field, but it also has session2, so maybe I cant use parameters to split up a field name?
I have been using
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
but I just get a blank screen Thanks