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;
    }    

?>

Recommended Answers

All 7 Replies

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;

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

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

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;
    }    

?>

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.

got it to work. I had to remove $_Get from $p

That is what I said in my previosu post :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.