I'm trying to make a working login page, and I want to keep track of the successful and unsuccessful logins for the user.
I'm trying to do this with an update statement in php:
$updateSQL="UPDATE login SET successfulLogins = IFNULL(successfulLogins, 0) + 1
WHERE username ='". $user ."'";
$updateStmnt=$dbcon->prepare($updateSQL);
$updateStmnt->execute();
Which gives me the error: Fatal error: Call to a member function execute() on a non-object
I tried manually entering the update statement in the database using SQL and it worked fine, so the issue is something to do with the php.. I think
Thanks
EDIT: I fixed this problem by closing dbcon earlier in the code, but now I have the same issue with this code:
$isError=true;
$errorMessage.="Username or password is incorrect<br />";
$updateSQL="UPDATE login SET unsuccessfulLogins = IFNULL(unsuccessfulLogins, 0) + 1
WHERE username ='". $user ."'";
$updateStmnt=$dbcon->prepare($updateSQL);
$updateStmnt->execute();
I am now getting :
Warning: mysqli::prepare(): Couldn't fetch mysqli Fatal error: Call to a member function execute() on a non-object