MYSQL更新连接错误 - >

I am doing an update statement into my database. My connection has been done properly. However there is an issue. After $conn-> the remaining of my codes are being displayed out just like echo instead of the update statement updating the database. I have been trying to debug it but nothing seems to work. Unsure of the error. Do help to identify the error.

   <?php//check on the updating
   if (isset($_POST['set'])){
       $query = 'UPDATE default SET sql_statement ="'.$_POST['sql'].'", x_axis = "'.$_POST['x'].'", y_axis = "'.$_POST['y'].'" WHERE id = "'.$id.'" ';
       $result = $conn->query($query);
       if($result){
           header('Location:previewgraphs.php?id='.$id);
           die();
       }
 }
 ?>

Some where your php tags have problem. So use " to wrap and also when you are using array index in concatenation, wrap them with {}

<?php 
   if (isset($_POST['set'])){
   $query = "UPDATE default SET sql_statement ='{$_POST['sql']}', x_axis ='{$_POST['x']}', y_axis = '{$_POST['y']}' where id = $id";
   $result = $conn->query($query);
   header('Location:previewgraphs.php?id='.$id);
   }
?>

Try this:

 <?php//check on the updating
       if (isset($_POST['set'])){
       $query = 'UPDATE default SET sql_statement ="'.$_POST['sql'].'", x_axis = "'.$_POST['x'].'", y_axis = "'.$_POST['y'].'" WHERE id = "'.$id.'" ';
       $result = $conn->query($query);
       if($result){
       header('Location:previewgraphs.php?id='.$id);
       die();
       }
     }
       ?>
<?php//check on the updating
               if (isset($_POST['set'])){
               $query = "UPDATE default SET sql_statement ='".$_POST['sql']."', x_axis = '".$_POST['x']."', y_axis = '".$_POST['y']."' WHERE id = '".$id."'";
               $result = $conn->query($query);
               if($result){
               header('Location:previewgraphs.php?id='.$id);
               die();
               }
             }
             ?>