Schwarz Spiel
Schwarz Spiel

Reputation: 31

Fatal error: Call to undefined method PDO::bindparam()

$txtEmail = $_POST['txtEmail'];
$txtPassword = $_POST['txtPassword'];

echo $txtEmail."<br>";
echo $txtPassword."<br>";

$DBH->prepare("SELECT * FROM adm_login_info WHERE cEmail=$txtEmail AND cPassword=$txtPassword AND cLoginStat=1 AND cLock=0 ");
$STHA->bindparam(":txtEmail",$txtEmail);
$STHA->bindparam(":txtPassword",$txtPassword);
$STHA->execute();

Please I need your help, I'm trying to solve this. Please Check on my codes if there is something I missed out.

Upvotes: 1

Views: 2917

Answers (1)

low_rents
low_rents

Reputation: 4481

bindParam is a method of a PDO statement, but you are trying to use it with the undefined variable $STHA.

preparing a SQL query with your database handler ($DBH->prepare(...) in your case) returns a PDO statement. you have to use this to bind parameters and execute your query:

$STHA = $DBH->prepare(...); // prepare returns a "statement"
$STHA->bindParam(...); // use the statement to bind your parameters
// ...
$STHA->execute()

also notice that bindParam is written with a capital P.

update: you are also not using your named parameters in your SQL query, you are just using your PHP variables. use the named parameters instead:

$DBH->prepare("SELECT * FROM adm_login_info 
WHERE cEmail = :txtEmail 
AND cPassword = :txtPassword AND cLoginStat=1 AND cLock=0 ");

Upvotes: 1

Related Questions