![]() |
| ||
| My script needs help-Calculate a Paycheck HI Can someone please help me. the book sucks, teacher will not help me (says I will not learn), I am trying to calculate Pay check. Just hours worked, pay, and overtime. :rolleyes: Script is as follows: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" Thanks |
| ||
| Re: My script needs help-Calculate a Paycheck Where are you having problems? |
| ||
| Re: My script needs help-Calculate a Paycheck When it shows in the browser, part of the code (with the if expressions ..I think) shows on the site. Also when I hit Submit, I do not get results. I know it is probably really simple, but I am very frustrated because I cannot find answers or a pattern to go by. Thanks for replying and I will be so grateful. I am behind on all my projects for PHP class. |
| ||
| Re: My script needs help-Calculate a Paycheck Look at the lines where you have $x =, $y =, etc. Firstly, you are trying to set one variable equal to another, but you aren't putting dollar signs in front of all your variables. It should be $x = $hoursWorked and not $x = hoursWorked. Also, you're setting $zz equal to $overtimeHours but that variable isn't set.I haven't had a chance to look over any of your logic yet. This is just syntax errors. |
| ||
| Re: My script needs help-Calculate a Paycheck Quote:
Thanks and Blessings:sad: |
| ||
| Re: My script needs help-Calculate a Paycheck Refer to my next post, I accidentally submitted my reply twice. Sorry |
| ||
| Re: My script needs help-Calculate a Paycheck I've checked ur code and you seem to lack a lot of ";" at the end of your statements and the reason that the value of $payCheck is not displayed is because: 1) $_REQUEST["payCheck"] is empty 2) Your computation is not really a computation but a string that shows how the computation is done 3) Also when computing, the result is assigned as if it was assigning a value to a variable. it should be $z = $x * $y, not $x * $y = $z. 3) You're trying to printout the value of $paycheck when in fact it should be $payCheck, remember php variables are case sensitive To solve your problem here's what you need to do: 1) correct your computation statement and assign the result to $paycheck 2) do not represent your computation as a string and don't enclose your strings in "(" and ")" 3) assign the result to a variable and output that variable in your echo statement Other things to do: 1) remove these lines because the request data you are trying to get are never set therefore they are useless $pay = $_REQUEST["pay"]2) The logic for your computation with overtime pay is kind of odd because you only compute for the overtimed hours when in fact it should be added to the wage for the normal hours worked. Instead of "$z = $x - 40 * $y * 1.5", it should be "$z = ($x *$y) + (($x - 40) * $y * 1.5)". Where "($x * $y)" computes for the wage for regular hours worked and "(($x - 40) * $y * 1.5)" computes for the wage for overtime hours. I debugged this locally and this is what I've done to make it work so there shouldn't be anymore problems. Cheers! |
| ||
| Re: My script needs help-Calculate a Paycheck HI jb thanks it worked! I appreciate you taking the time and pointing out my mistakes. Even if I had the syntax correct, I knew I was leaving out something in my overtime. regards wavyaquaeyes |
| ||
| Re: My script needs help-Calculate a Paycheck Quote:
|
| All times are GMT -4. The time now is 7:21 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC