Jump to content

INSERT issue


TapeGun007
Go to solution Solved by Barand,

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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.