php - mySQL table updates, but not fast enough for a select statement on the same page to access the updates - any ideas? -


i trying write code updates mysql table, , selects out of same table in same page. however, find when update query, select query, not recognize changes. if, however, refresh page, recognized changes.

i first have insert statement this

$query = 'insert matches (uid, win) values ($uid, $win)';  mysql_query($query) or die(mysql_error() . ' in ' . $query); 

then, after this, have select statement like

$query = "select * matches uid = $uid";  $resultmain = mysql_query($query) or die(mysql_error() . ' in ' . $query); 

of course simplified queries but, general idea - , happens is: select statement not recognize update run before it. however, if reload page, , select statement runs again after time, recognize change.

i googled , surprised not come across yet. there way force wait until mysql update query finished before selecting? if not, might have use javascript automatically reload page, sounds messy solution.

any appreciated, has been driving me crazy...

--anthony

that should not happen. maybe it’s problem in code, did not post?

things come mine, problem:

the 2 queries run on different connections mysql database. , auto-commit not enabled.

thus, first query send update not commit, second query query on old data, , after page finishes (/later on) commit occurs.

i’m not quite sure if non-auto-commited changes commited or rolled when php script ends, should rollback. later commit needed in code possible scenario apply.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -