0

I keep getting this error message: Parse error: syntax error, unexpected 'Your' (T_STRING) in C:\xampp\htdocs\Salary.php on line 8.

<?php
    $h=$_GET['hours'];
    $r=$_GET['rate'];
    $p=$_GET['pay'];

    if ($h <= 40){
    $submit = ("$p = $h * $r)
    echo  "Your Weekly Salary Is: $p;
    }
    if ($h > 40){
    $submit = ("$p = ($h *$r) + (($h - 40) * $r * 1.5)")
    echo "Your Weekly Salary Is: $p;
    }    

?>
2
Contributors
7
Replies
29
Views
4 Years
Discussion Span
Last Post by simplypixie
0

You are missing ending semi-colons on some of your lines and also not closing your " on your echos

$p = $h * $r;
echo  "Your Weekly Salary Is: ".$p;



$p = ($h * $r) + (($h - 40) * $r * 1.5);
    echo "Your Weekly Salary Is: ".$p;

Edited by simplypixie

0

I changed what you said however I am still getting the same message.

0

Looking again, your $submit variables are incorrect, they should be $p and no qutore marks are required. I have amended my post above to correct those ares

0

I see. This is what i changed it to. But now its doing this: Notice: Undefined index: pay in C:\xampp\htdocs\Salary.php on line 4
Your Weekly Salary Is:

<?php
    $h=$_GET["hours"];
    $r=$_GET["rate"];
    $p=$_GET["pay"];

    if ($h <= 40){
    $submit = $p = $h * $r;
    echo  "Your Weekly Salary Is: ".$p;
    }
    if ($h > 40){
    $submit = $p = ($h *$r) + (($h - 40) * $r * 1.5);
    echo "Your Weekly Salary Is: ".$p;
    }    

?>

Edited by vato116

0

That would be because you don't have 'pay' in your url so the $_GET['pay'] is empty as it doesn't exist. I don't see why it is needed so just remove that line.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.