Slow MYSQL Inserts?

I’ve been doing some backend debugging of the members area since a few of the recent purchases have been processed incorrectly and have found that SQL inserts into my user table seem to be delayed.  My PHP continues BEFORE the insert seems to complete.  No, I’m not using “INSERT DELAYED”.

For example (note, this isn’t my DB setup, it’s just an example):

$query = "INSERT INTO users ( `ID` , `email` , `password`) VALUES ( '10', 'myemail@email.com', '12345')";
mysql_query ($query) or die ('Could not create user.');
$query = "SELECT id FROM users WHERE email = 'myemail@email.com'";
$result = mysql_query($query);

This should give me a result set consisting of the 10…instead it gives me nothing.  In debugging, both queries work, so it’s not a syntax error.  And viewing the table after the fact, the record appears correct.  As a workaround, I currently close the database connect between the two mysql_query()…but that seems like a
silly thing to need to do.

Any thoughts?

Related Posts:

Posted Wednesday, April 30th, 2008 under Our Stuff.

Tags: ,

2 comments

  1. In your example, it should be
    SELECT ID not id

  2. Actually, it was the other way around…lowercase. Still, not sure if that was the culprit or not. Thanks for pointing that out!

Leave a Reply