1

I am getting an error on the $db line. I have tried placing a '->" before the prepare but then I get a Parse Error Syntax Error.

//try to login  
$db = pdo-prepare($sql);  
$username = $db->bindValue($_POST['username']);  
$password = $db->bindValue($_POST['password']);  
$tablePrefix = "";  
$UserAndPassTable = $tablePrefix . "user";
Andrew P
  • 11
  • 2
  • You need to set your PDO connection into `$db` before you can call `prepare()` . Then it would be `$db->prepare($sql)` I think this post gives real good information on how to use PDO prepared statements. http://stackoverflow.com/a/767520/6208463 – Jason Joslin Apr 23 '17 at 01:59

1 Answers1

2

You need to set your PDO connection into $db before call prepare()

$stmt=$db->prepare($sql);

In my example $db is my PDO connection

$db = new PDO('mysql:host=localhost;dbname;charset=utf8', 'user', 'pass');
Daniel Paiva
  • 121
  • 2
  • 10