Hello everybody,
I need some help, and it has been doing my head in.
I am trying to use PDO to select a single record in my database. The easiest way to describe it, is I am trying to use my $_SESSION[‘username’] variable to pull my user record from MySQL. If I click on my username in my php I want to display my database record based on my username.
The script I have been trying to use is:
[php]try
{
$sql = “SELECT * FROM member WHERE username = :username”;
$s = $pdo->prepare($sql);
$s->bindValue(’:username’, $_SESSION[‘username’]);
execute();
}
catch (PDOException e$)
{ etc etc etc…[/php]
I am getting the error
Fatal Error: Call to a member function prepare() on a non-object in [.php path] on line 53
I run the file just using echo $_SESSION[‘username’] and get the result of admin, which is what I want to be searching the database for.
Any help would be greatly appreciated.