dudejma Posted January 3, 2012 Share Posted January 3, 2012 I have this query: $sql3 = "UPDATE users SET hours = '$newHours', pay = '$newPay', virtualLocation = '$arrival', expDate = '$expDate' WHERE pilotID = '$pilotid'"; I've echoed it out and all the variables put out the correct values. The query works except for the pay section of it. It will update the hours, virtual location, and expiration date but it will not update the pay. It inputs 1.00 when the value echoed in the query is not 1.00. I'm not sure if, because it is a decimal, it changes how the query works. Any help? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/254246-mysql-update/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 3, 2012 Share Posted January 3, 2012 What's the actual value are you putting into the query for the pay? What is your pay column definition? Quote Link to comment https://forums.phpfreaks.com/topic/254246-mysql-update/#findComment-1303559 Share on other sites More sharing options...
dudejma Posted January 3, 2012 Author Share Posted January 3, 2012 'pay' value = '1313.40' The pay column is: decimal(10,2). Quote Link to comment https://forums.phpfreaks.com/topic/254246-mysql-update/#findComment-1303560 Share on other sites More sharing options...
PFMaBiSmAd Posted January 3, 2012 Share Posted January 3, 2012 There's nothing technically wrong with what you have posted that would cause the problem. How are you looking at the result that shows the 1.00 in the field? Perhaps something in the display logic is causing the symptom? Have you looked directly in the database table using your favorite database management tool? I suspect that your php logic is either executing another query (or the same one but with a 1 for the value) or something in your whole code is setting the value to a 1. Given that you have a $sql3, implying a $sql1, $sql2, and perhaps a $sql4,... posting enough of your code (less your database username/password) needed to reproduce the problem would be the quickest way of pinning down where the problem is. Quote Link to comment https://forums.phpfreaks.com/topic/254246-mysql-update/#findComment-1303742 Share on other sites More sharing options...
dudejma Posted January 3, 2012 Author Share Posted January 3, 2012 $sql1 & $sql2 are both select queries. There is a $sql4 but it is commented out at this time (/* & */). It updates another table. It does change a value to 1, but the column doesn't have the same name as pay and is, like I said, in another table. I'm not an expert programmer by no means, so my code is sort of confusing; after a while of breaking down each chunk, I still can't find what's wrong. There is nothing between the $sql3 and the execution of it. There is nothing after it except for a redirect to the same page but the $sql3 execution section is only run if the approve button is set. Are there certain parts of it that you would like to see? Quote Link to comment https://forums.phpfreaks.com/topic/254246-mysql-update/#findComment-1303926 Share on other sites More sharing options...
Pikachu2000 Posted January 4, 2012 Share Posted January 4, 2012 You're going to need to post more of the code, from where the variables are assigned values to after the query executes. Quote Link to comment https://forums.phpfreaks.com/topic/254246-mysql-update/#findComment-1303932 Share on other sites More sharing options...
jcbones Posted January 4, 2012 Share Posted January 4, 2012 Have you tried to put the query directly in the console or other database software (phpmyadmin)? Quote Link to comment https://forums.phpfreaks.com/topic/254246-mysql-update/#findComment-1303937 Share on other sites More sharing options...
PFMaBiSmAd Posted January 4, 2012 Share Posted January 4, 2012 Your code is doing something that is causing this. Within your programming/troubleshooting ability and knowledge, you cannot troubleshoot the problem. You are asking people who are not standing right next to you to help you with what your code is doing. Without having enough of your actual code that you have specifically tested that produces/reproduces this problem, no one here can help you. We can only make guess that can be no better than the information that you have supplied. Since you mention redirecting, I will guess that you don't have an exit; statement after your header redirect and your code that is continuing to run while the browser performs the redirect is causing this. Second guess - your code is not testing if a form was submitted at all and upon the redirect is executing the update query again with a 1 for the pay value. Third guess - your code is dynamically getting the table name for the query and the logic is getting the wrong one or is putting the wrong one in. Fourth guess - register_globals are on and is overwriting your program variables from post/get/cookie/session variables. Quote Link to comment https://forums.phpfreaks.com/topic/254246-mysql-update/#findComment-1303943 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.