我的pdo语句中的错误

For my project i'm trying to predict a paststudent's A level maths grade by using past student's data in my database. So paststudent1 got an A in maths A level. In year one exams they got an A in Computing, B in Physics, A in Chemistry, Male and 97% attendance. If the current student in Year 1 got the same grades, same subjects, male and same attendance i want to say they will get the same grade.

My error in my code says: "Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' grade1 = 'Maths', 'A'' at line 1' in /home/u717042829/public_html/predicter.php:70 Stack trace: #0 /home/u717042829/public_html/predicter.php(70): PDOStatement->execute() #1 {main} thrown in /home/u717042829/public_html/predicter.php on line 70"

Line 70 is:

            $query->execute();

.

<?php 
error_reporting(E_ALL); ini_set('display_errors', 1);
require("includes/config.php");
//if not logged in redirect to login page
if(!$user->is_logged_in()){ header('Location: login.php'); } 

//define page title
$title = "Predict a Student's Grade";

?>
<!DOCTYPE html>
<html>



<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Past Student</title>

    <!-- Bootstrap Core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

  


    <!-- Custom Fonts -->
    <link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<body>




<?php 

    if (isset($_POST['name'])) {


        $name     = $_POST['name'];
        $subject1 = $_POST['subject1'];
        $grade1   = $_POST['grade1']; 
        $subject2 = $_POST['subject2'];
        $grade2   = $_POST['grade2'];
        $subject3 = $_POST['subject3'];
        $grade3   = $_POST['grade3'];
        $subject4 = $_POST['subject4'];
        $grade4   = $_POST['grade4'];
        $attendance = $_POST['attendance'];
        $gender     = $_POST['gender'];


            $query = $db->prepare("SELECT * FROM paststudent WHERE subject1, grade1 = :subject1, :grade1");
            $query->bindParam(':subject1', $subject1);
            $query->bindParam(':grade1', $grade1);
            $query->execute();

          
            




    }
    ?>
    <h1> Your predicted grade is <?php echo $query ?> </h1>

</body>
</html>

Right now i'm taking it in small steps matching subject 1 with grade 1 then doing subject 2 grade 2 as i get it too work.

</div>

This part of your query looks incorrect:

WHERE subject1, grade1 = :subject1, :grade1

you most likely meant it to be altered to look like this:

WHERE subject1 = :subject1 AND grade1 = :grade1

so your final version of that line should read:

$query = $db->prepare(  " SELECT * FROM paststudent "
                      . " WHERE subject1 = :subject1 AND grade1 = :grade1");

I recommend reading some tutorials on SQL basics.

This is not how you get results from PDO,try

<body>
<table>
....


$query->execute();

          }
while($row = $query->fetch(PDO::FETCH_ASSOC)){

      echo "<tr><td>".$row['user']."</td></tr>"; --change user to what the column is actually called
}

    ?>
</table>  
</body>
</html>