Mr Chris Posted October 20, 2010 Share Posted October 20, 2010 Hello All, Trying to write a log-in script using PDO. But have one question. With the below when I query the database and even run a print_r on $RES nothing is outputted? Any ideas? Thanks if (isset($_POST['Submit'])) { $email = $_POST['email']; $password = $_POST['password']; $QUERY = $dbc->prepare("SELECT email, password FROM tbl WHERE email = :email"); $QUERY->bindParam(':email', $email); $QUERY->execute(); $RES = $QUERY->fetchColumn(); echo "Email is:".$RES['email']; echo "PW is: ".$RES['password']; print_r($RES); } Quote Link to comment https://forums.phpfreaks.com/topic/216394-using-pdo-to-query-a-database/ Share on other sites More sharing options...
AbraCadaver Posted October 20, 2010 Share Posted October 20, 2010 fetchColumn() as you are using it only returns the value of the first column in the first row. You probably want fetch() to fetch the entire row. Also, if there is nothing there, then there were no results returned. Quote Link to comment https://forums.phpfreaks.com/topic/216394-using-pdo-to-query-a-database/#findComment-1124619 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.