TapeGun007 Posted July 28, 2015 Share Posted July 28, 2015 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? Quote Link to comment Share on other sites More sharing options...
Solution Barand Posted July 28, 2015 Solution Share Posted July 28, 2015 Try outputting $con->error instead of $conn->error and see if that gives a message Quote Link to comment Share on other sites More sharing options...
TapeGun007 Posted July 28, 2015 Author Share Posted July 28, 2015 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. Quote Link to comment Share on other sites More sharing options...
TapeGun007 Posted July 28, 2015 Author Share Posted July 28, 2015 I had a mySQLi prepared statement that was just before that initial IF THEN. I put $stmt->close(); just before the IF THEN and that fixed the error. Thank you for helping me find the correct error message! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.