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); } 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. 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
Archived
This topic is now archived and is closed to further replies.