Click here to Skip to main content
15,885,435 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Writing a php code, it's erroring out at over 40 hours. Have tried to correct but I can't find the issue. PLEASE HELP. I've submitted it already, just need to make that one correction to be regraded.

40 hours
    else if($hourly > 40){
        echo "Total pay is: ".(($hourly * $regular_pay)+ $hourly -40( * $overtime_pay) + $tips);
    }
}

//test the input data
function test_input($data) {
  $data = trim($data);
  $data = stripslashes($data);
  $data = htmlspecialchars($data);
  return $data;
}

?>

What I have tried:

I can't find the error, I've changed everything in the >40 hours code, but I still can't get it to calculate correctly. Any suggestions would be helpful.
Posted
Comments
[no name] 18-Nov-22 21:37pm    
You just have "hours"; you need to calculate regular and overtime hours. Your "one liner" isn't doing it.
Kornfeld Eliyahu Peter 21-Nov-22 3:54am    
It seems to me a execution order problem... Means you have the wrong order/placement of parentheses around the computation...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900