Jump to content

MySQL Update


dudejma

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

$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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.