PHP代码 - 返回错误[关闭]

I am trying to automate an email alert after checking a sql query first.

As I am not so familiar with php I found a code for that purpose however there is row 29 that returns me an error.

   while($row = mysqli_fetch_array($result))
  {
  $message = {$row['User Name'] . " " . $row['Email']. " " . $row['Course']. " " .      $row['Attempt']. " " . $row['Grade']. " " . $row['Finish time']
};
  }

Please advise. You can find below all the code. Thank you.

<?php
$con=mysqli_connect("localhost","user","pass","db");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

$result = mysqli_query($con,"SELECT
us.username AS 'User Name',
us.email AS 'Email',
qu.name AS 'Course',
quat.attempt AS 'Attempt',
quat.sumgrades AS 'Grade',
FROM_UNIXTIME(quat.timefinish,'%M %D %Y %h:%i:%s') AS 'Finish time'
FROM mdl_quiz_attempts AS quat
JOIN mdl_user AS us ON quat.userid=us.id
JOIN mdl_quiz AS qu ON quat.quiz=qu.id
WHERE (quat.attempt = 3 OR quat.attempt = 6) AND quat.sumgrades < 80 AND quat.timefinish > (unix_timestamp(now())-300)
ORDER BY us.username,qu.name,quat.attempt");

if($result->num_rows>=1) {
   $email='dc@antaea.com';
   $subject = "E-School failed attempts";
   $message='One or more users failed quiz three or more times:

';

   while($row = mysqli_fetch_array($result))
  {
  $message = {$row['User Name'] . " " . $row['Email']. " " . $row['Course']. " " . $row['Attempt']. " " . $row['Grade']. " " . $row['Finish time']
};
  }

  if(mail($email, $subject, $message)) {
      //mail successfully sent
   } else {
      //mail unsuccessful
   }
}

mysqli_close($con);
?>

Try with that (with the as a string at the end):

   while($row = mysqli_fetch_array($result)){
  $message = {$row['User Name'] . " " . $row['Email']. " " . $row['Course']. " " .      $row['Attempt']. " " . $row['Grade']. " " . $row['Finish time'] . "
"};
  }

Escaped characters can not use with single quote, you must double Single quote for this like " "