Jump to content

INSERT issue


TapeGun007

Recommended Posts

I'm beating my head against the wall trying to figure out what I've changed.  This INSERT near the bottom was working.  I changed something and now it fails every time.

 

 

        if($Email == $Username && $Pass == $Password){
            {set session ID's}
 
            // $stmt->close();
            
            // If the login is successful, then go ahead and UPDATE and override all failed attempts.
            $sql = "UPDATE LoginAttempts SET LACleared = 'yes' WHERE LASalesID = '$ID'";
            if ($con->query($sql) === TRUE){
                echo "Login Successful";
            }else{
                echo "Error updating record";
            }
            // $con->close();
            
            // Redirect to crm.php
            header('Location: crm.php');
            die();
        }else{
            $sql="INSERT INTO LoginAttempts (LASalesID) VALUES ('10000')";
             
            if ($con->query($sql) === TRUE) {
                echo "New record created successfully";
            } else {
                echo "Error: " . $sql . "<br>" . $conn->error;  <---- I get this error every time.
            }
            
            $con->close();

 

So at the bottom, I get the Echo "Error: " with the sql string every single time.  I have no idea what I've done wrong.  All the other fields in the table LoginAttempts are set to default one of which is a TimeStamp in mySQL.

 

I know that the $con is fine because I use it early to verify the username is correct from another table.  What am I doing wrong here?

 

 

Link to comment
https://forums.phpfreaks.com/topic/297502-insert-issue/
Share on other sites

Error: INSERT INTO LoginAttempts (LASalesID) VALUES ('10000')
Commands out of sync; you can't run this command now

 

Good catch Barand.  I was using code from another site and apparently didn't fix all the conn to con's.  At least I can Google this error message and see if that helps.

Link to comment
https://forums.phpfreaks.com/topic/297502-insert-issue/#findComment-1517513
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.