I'm currently working on a comment section for products review. It is a form that sends back data to PHP will display the comments and all of the comments will be sent to MYSQL database but I got this error:
Parse error: syntax error, unexpected 'var' (T_VAR) in C:\Users\USER\Desktop\XAMPP\htdocs\ecom\resources\functions.php on line 390
Any help is appreciated, thank you.
These are my codes:
Functions.php
function post(){
  LINE 390:: var comment = document.getElementById("comment").value;
  var name = document.getElementById("username").value;
  if(comment && name)
  {
    $.ajax
    ({
      type: 'post',
      url: 'post_comment.php',
      data: 
      {
         user_comm:comment,
         user_name:name
      },
      success: function (response) 
      {
        document.getElementById("all_comments").innerHTML=response+document.getElementById("all_comments").innerHTML;
        document.getElementById("comment").value="";
        document.getElementById("username").value="";
      }
    });
  }
  return false;
}
Item.php
<div id="all_comments">
      <?php
      post();
      ?>
  <?php
    $comm = mysql_query("select name,comment,post_time from comments order by post_time desc");
    while($row=mysql_fetch_array($comm))
    {
      $name=$row['name'];
      $comment=$row['comment'];
      $time=$row['post_time'];
    ?>
    <div class="comment_div"> 
      <p class="name">Posted By:<?php echo $name;?></p>
      <p class="comment"><?php echo $comment;?></p> 
      <p class="time"><?php echo $time;?></p>
    </div>
    <?php
    }
    ?>
  </div>
