0

Im getting an Error:

FATAL ERROR: Function name Must be a string in C:\xampp\localhost\student\viewgrades.php on line 78.

I wanted to make an if Statement if the grade is more than 75 then it should echo 'passed', but if the calculated grade is below 75 i should 'echo failed'.

Sorry for the code structure my knowledge for PHP is still limited

<?php
$resultp = mysql_query("SELECT * FROM prelcent");
$row = mysql_fetch_array($resultp);

$prelcent=$row['percentage'];

$resultpp = mysql_query("SELECT * FROM midcent");

$row = mysql_fetch_array($resultpp);

$midcent=$row['percentage'];

$resultppp = mysql_query("SELECT * FROM precent");

$row = mysql_fetch_array($resultppp);

$precent=$row['percentage'];

$resultpppp = mysql_query("SELECT * FROM fincent");

$row = mysql_fetch_array($resultpppp);

$fincent=$row['percentage'];

$remark = (($pre*$prelcent)+($mid*$midcent)+($prf*$precent)+($fin*$fincent));
    if ($remark() >75)   <<<<<Line 78 {
        $rem1 = "echo 'passed!';";
    } else {
        if ($remark()<75) {
            $rem1 = "echo 'failed';";
        }
    }
    echo "<td>". $rem1 ."</td>"
?>

3 Answers 3

4

Can you try with

if ($remark >75) 

Because $remark is not a function.Its a variable that to the result of

($pre*$prelcent)+($mid*$midcent)+($prf*$precent)+($fin*$fincent)
Sign up to request clarification or add additional context in comments.

Comments

2

$remark is variable, not a function, So it should be , also $rem1 = "passed!"; instead of $rem1 = "echo 'passed!';";

if ($remark > 75){
     $rem1 = "passed!";
}

instead of

if ($remark() > 75){
   $rem1 = "echo 'passed!';";
}

Your code should be like,

 $remark = (($pre*$prelcent)+($mid*$midcent)+($prf*$precent)+($fin*$fincent));
 if ($remark > 75) {
    $rem1 = "passed!";
 } else {
    if ($remark < 75) {
        $rem1 = "failed";
    }
 }
 echo "<td>". $rem1 ."</td>";

Comments

0

$rem1 = "echo 'passed!';"; makes it look like a function. In order for it to look like a variable it should be $rem1 = "passed!";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.