DavidAl Posted June 19, 2009 Share Posted June 19, 2009 Hello, I have a problem with a SELECT that *sometimes* doesn't show the row from a previous INSERT. It fails around 1 call of every 10. The structure I have is the following: 1) HTML button: calls the javascript function insertAndList(). 2) insertAndList(): calls the javascript function insert() which through AJAX executes a PHP that inserts a row in a MySQL databas. 3) inserAndList(): calls the javascript function list() which through AJAX executes a PHP that lists the table. If I add a delay of 100ms between 2) and 3), the list() function fails much less often, around 1 of every 100. Is there a way to force the SELECT to "refresh" the buffer or whatever it is that is showing the old number of rows? (i'm not using MySQL CACHE, as far as I know). Link to comment https://forums.phpfreaks.com/topic/162893-solved-select-not-showing-previous-insert/ Share on other sites More sharing options...
kickstart Posted June 19, 2009 Share Posted June 19, 2009 Hi I would be tempted to trigger your 2nd Javascript function based on the completion of the first. All the best Keith Link to comment https://forums.phpfreaks.com/topic/162893-solved-select-not-showing-previous-insert/#findComment-859522 Share on other sites More sharing options...
gevensen Posted June 19, 2009 Share Posted June 19, 2009 have you tried assigning the row id to a variable right after the 1st call and using that variable later, kind of a saved point of reference? Link to comment https://forums.phpfreaks.com/topic/162893-solved-select-not-showing-previous-insert/#findComment-859570 Share on other sites More sharing options...
fenway Posted June 22, 2009 Share Posted June 22, 2009 This is so very much not a mysql issue... there's a race condition, or the usual asynchronous games. Link to comment https://forums.phpfreaks.com/topic/162893-solved-select-not-showing-previous-insert/#findComment-860985 Share on other sites More sharing options...
DavidAl Posted June 22, 2009 Author Share Posted June 22, 2009 Thanks for the replies. I see what you mean, but... how does the list() function *wait* until it gets the control variable filled from the insert() function? Sorry I'm pretty new at javascript and AJAX. Link to comment https://forums.phpfreaks.com/topic/162893-solved-select-not-showing-previous-insert/#findComment-861364 Share on other sites More sharing options...
DavidAl Posted June 22, 2009 Author Share Posted June 22, 2009 Sorry I'm abusing the MySQL forum. Will mark this as solved and look elsewhere. The "Race condition" opened the door to the real issue here. Thanks a lot. Link to comment https://forums.phpfreaks.com/topic/162893-solved-select-not-showing-previous-insert/#findComment-861369 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.