MasterACE14 Posted October 16, 2008 Share Posted October 16, 2008 I have this basic UPDATE query... UPDATE `UserDetails` SET `gold`=`gold`+((`untrainedSold`*10)+(`miners`*25)) untrainedSold has the value 181 and miners is 3,593 The value I am expecting to be added to gold from this query is 91,635 but its currently adding around 7 million. Any ideas why? Quote Link to comment https://forums.phpfreaks.com/topic/128693-solved-wrong-result-from-update-query/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 16, 2008 Share Posted October 16, 2008 Try the following to see what it evaluates to - SELECT ((`untrainedSold`*10)+(`miners`*25)) If that value is correct, then your query is probably being executed multiple times. Quote Link to comment https://forums.phpfreaks.com/topic/128693-solved-wrong-result-from-update-query/#findComment-667049 Share on other sites More sharing options...
MasterACE14 Posted October 17, 2008 Author Share Posted October 17, 2008 when I run that, the value is correct. how do I determine whether the query is being executed multiple times? Quote Link to comment https://forums.phpfreaks.com/topic/128693-solved-wrong-result-from-update-query/#findComment-667744 Share on other sites More sharing options...
PFMaBiSmAd Posted October 17, 2008 Share Posted October 17, 2008 Use a session with a counter in it or use the php error_log() function to write information about your queries to a log file. The mysql built-in query log also shows the date/time, mysql user, and the actual query. Quote Link to comment https://forums.phpfreaks.com/topic/128693-solved-wrong-result-from-update-query/#findComment-667749 Share on other sites More sharing options...
MasterACE14 Posted October 17, 2008 Author Share Posted October 17, 2008 I found the problem. the query was within a large 'for' loop which covered most of the file. Thanks for your help PFMaBiSmAd much appreciated! Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/128693-solved-wrong-result-from-update-query/#findComment-667838 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.