I have the following
$subUsername = trim($_POST["user"]); $sql = "SELECT userID, username, password FROM user WHERE username = ':user')"; $q = $conn->prepare($sql); $q->bindParam(':user', $subUsername); $q->execute(); $result = $q->fetch(PDO::FETCHASSOC); print_r($result); echo "</p>"; print_r($subUsername); echo "</p>"; print_r($subPassword);
$result is always just an empty array, if I run the SQL on the database it works fine. Is anything obviously wrong?
The username and password print fine using