tracivia Posted March 22, 2009 Share Posted March 22, 2009 Hi, i am a self taught PH developer. While ago, i wrote a large PHP application. I write object oriented code and PHP5 without any errors. Sometimes we get wrong values and it happens mostly if the server (or db) is bussy. My question is, how can i avoid that kind of exceptions. I've tuned the server little but i am not sure if it's the right solution. I mean, i can't do like that: $a = getTheValues(POST['val']); ... $b = getTheValues(POST['val']); return ($a == $b) ? $a : false; So, what do you use to ensure about these exceptions. What could be the reason of these errors? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/150574-i-am-having-random-errors/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 22, 2009 Share Posted March 22, 2009 Your post contains no useful information for anyone to be able to help you. Reread it and ask yourself if anyone could tell from it what symptoms you even saw in front of you when your code runs? About the only thing anyone can say based on the information in your post is your code probably does not have any logic in it for error checking (check if something worked or not and validate external data before using it), error reporting (output a meaningful user error message and log all relevant information about what happened), or error recovery (what does your code do when an error occurs, blindly continue execution using nonexistent data or gracefully terminate.) Quote Link to comment https://forums.phpfreaks.com/topic/150574-i-am-having-random-errors/#findComment-790928 Share on other sites More sharing options...
Maq Posted March 22, 2009 Share Posted March 22, 2009 I don't understand how your code relates to your problem or the point of it. Unless your "getTheValues()" function has some random generation in it, or the ... changes the value of $a, then you're always going to return $a. Quote Link to comment https://forums.phpfreaks.com/topic/150574-i-am-having-random-errors/#findComment-790930 Share on other sites More sharing options...
tracivia Posted March 22, 2009 Author Share Posted March 22, 2009 -Sometimes we get wrong values- If you really need an example, i get 3 instead of 5 or 20 instead of 2.05, it doesn't matter . The problem is getting wrong values from the database. And as i said, this error occours random, so i posting a piece of PHP code is useless since there is nothing to discuess in it. I assume it's a performance issue since the application uses heavy mysql sources. My question is: -Have you ever had similar problems -What are the possible causes -Do you know any work around for that problem Besides that, if you need any extra info, just ask. Quote Link to comment https://forums.phpfreaks.com/topic/150574-i-am-having-random-errors/#findComment-791131 Share on other sites More sharing options...
Maq Posted March 22, 2009 Share Posted March 22, 2009 It's really impossible to help unless you show us some code that you get wrong results from. I don't see how overworking the server could result in wrong data, maybe slower, or poor performance, but not incorrect results. Give us a piece of code, and a random result? Is it possible your code contains errors that produces these incorrect results. Sorry if I'm not providing help but maybe someone else who understands what you're saying can answer your question. Quote Link to comment https://forums.phpfreaks.com/topic/150574-i-am-having-random-errors/#findComment-791134 Share on other sites More sharing options...
PFMaBiSmAd Posted March 22, 2009 Share Posted March 22, 2009 Computers only do what their code tells them to do. If you are getting wrong results, then either the original data is incorrect or the code that is processing and outputting the result contains an error that under specific conditions produces the wrong value. Servers don't get tired and start making only random mistakes in numbers. A problem with a processor or memory that would cause data values to be randomly changed would cause programs to lock up as well. So, if the only symptom is randomly changed values, it is likely that your code is doing it, either for specific data values or under specific conditions. Have you looked directly in the database so that you know the input data is correct? The only other help possible is if you post the code that is responsible querying, retrieving, processing, and outputting the results along with a specific example of the input data and what the wrong output is for that input data and what the expected output should be. 1,000,000 different people could have posted your thread here and there could be a different problem with each of their programs that would cause the symptom you are getting. Without seeing the code and the data that is responsible for those symptoms there is no way that anyone else can determine what is causing the problem. Quote Link to comment https://forums.phpfreaks.com/topic/150574-i-am-having-random-errors/#findComment-791195 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.