Friday, 13 September 2013

Converting to OOP code stopped working

Converting to OOP code stopped working

I am trying to convert my functions file into an OOP file since I have
been reading that its that way to go. I am still learning and am still
confused about a lot in OOP but figured I would convert some things to
help understand it better. I am running into some trouble right now trying
to get data from my database. I am not getting anything printed to the
screen, no error messages either. What did I do wrong?
<?php
require 'resources/library/DB.php';
error_reporting(E_ALL);
$username = "test";
class userFunctions{
public function checkLogin($conn,$username) {
try{
$stmt = $conn->prepare('SELECT `password` FROM `users` WHERE
`userName`= :userName');
$stmt->bindValue(':userName', $username);
$stmt->execute();
$salt = $stmt->fetchColumn();
} catch (PDOException $e){
echo 'Connection failed: ' . $e->getMessage();
}
return $salt;
}
}
$a = new userFunctions;
$a->checkLogin($conn, $username);
echo $salt;
?>

No comments:

Post a Comment