I got this error and I can't solve it
Call to a member function bindParam() on a non-object in (7 line)
line - $statement->bindParam(':vardas', $_POST['vardas']);
The whole script
<?php
require 'db.php';
if(!empty($_POST['vardas']) && !empty($_POST['slaptazodis']) && !empty($_POST['email'])) {
$sql = "INSERT INTO nariai (vardas, email, slaptazodis) VALUES(:vardas, :email, :slaptazodis)";
$statement = $con->prepare($sql);
$statement->bindParam(':vardas', $_POST['vardas']);
$password_hash = password_hash($_POST['slaptazodis'], PASSWORD_BCRYPT);
$statement->bindParam(':slaptazodis', $password_hash);
$statement->bindParam(':email', $_POST['email']);
if($statement->execute()) {
$message = 'Account successfully created';
} else {
$message = 'Sorry, there must have been an issue creating your account. Try again later';
}
}
?>