title: Up or down voted content shows HTML code on vote
body: <p>Whenever I click up or down vote on my PHP/MySQL/JS vote system, it shows long list of HTML code. I don't know what is error, some people suggested me removing <code>unique_content_id</code> because there is blank row in table for that attribute and we don't know why. I will give it a shot and post here.</p>
  
  <p>Error:</p>
  
  <p><a href="http://pastebin.com/b0SQL7X4" rel="nofollow noreferrer">http://pastebin.com/b0SQL7X4</a></p>
  
  <p>vote_process.php file</p>
  
  <pre><code>if($_POST)
  {
  
      ### connect to mySql
      $sql_con = mysqli_connect($db_host, $db_username, $db_password,$db_name)or die('could not connect to database');
  
      //get type of vote from client
      $user_vote_type = trim($_POST["vote"]);
  
      //get unique content ID and sanitize it (cos we never know).
      $unique_content_id = filter_var(trim($_POST["unique_id"]),FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);
  
      //Convert content ID to MD5 hash (optional)
      $unique_content_id = hash('md5', $unique_content_id);
  
      //check if its an ajax request, exit if not
      if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
          die();
      }
  
  
      switch ($user_vote_type)
      {          
  
          ##### User liked the content #########
          case 'up':
  
              //check if user has already voted, determined by unique content cookie
              if (isset($_COOKIE["voted_".$unique_content_id]))
              {
                  header('HTTP/1.1 500 Already Voted'); //cookie found, user has already voted
                  exit(); //exit script
              }
  
              //get vote_up value from db using unique_content_id
              $result = mysqli_query($sql_con,"SELECT vote_up FROM crewlist WHERE unique_content_id='$unique_content_id' LIMIT 1");
              $get_total_rows = mysqli_fetch_assoc($result);
  
              if($get_total_rows)
              {
                  //found record, update vote_up the value
                  mysqli_query($sql_con,"UPDATE crewlist SET vote_up=vote_up+1 WHERE unique_content_id='$unique_content_id'");
              }else{
                  //no record found, insert new record in db
                  mysqli_query($sql_con,"INSERT INTO crewlist (unique_content_id, vote_up) value('$unique_content_id',1)");
              }
  
              setcookie("voted_".$unique_content_id, 1, time()+7200); // set cookie that expires in 2 hour "time()+7200".
              echo ($get_total_rows["vote_up"]+1); //display total liked votes
              break; 
  
          ##### User disliked the content #########
          case 'down':
  
              //check if user has already voted, determined by unique content cookie
              if (isset($_COOKIE["voted_".$unique_content_id]))
              {
                  header('HTTP/1.1 500 Already Voted this Content!'); //cookie found, user has already voted
                  exit(); //exit script
              }
  
              //get vote_up value from db using unique_content_id
              $result = mysqli_query($sql_con,"SELECT vote_down FROM crewlist WHERE unique_content_id='$unique_content_id' LIMIT 1");
              $get_total_rows = mysqli_fetch_assoc($result);
  
             if (!mysqli_query($result, "SET a=1")) {
      printf("Errormessage: %s\n", mysqli_error($result));
  }
  
              if($get_total_rows)
              {
                  //found record, update vote_down the value
                  mysqli_query($sql_con,"UPDATE crewlist SET vote_down=vote_down+1 WHERE unique_content_id='$unique_content_id'");
              }else{
  
                  //no record found, insert new record in db
                  mysqli_query($sql_con,"INSERT INTO crewlist (unique_content_id, vote_down) value('$unique_content_id',1)");
              }
  
              setcookie("voted_".$unique_content_id, 1, time()+7200);  // set cookie that expires in 2 hour "time()+7200".
              echo ($get_total_rows["vote_down"]+1);//display total disliked votes
              break; 
  
          ##### respond votes for each content #########     
          case 'fetch':
              //get vote_up and vote_down value from db using unique_content_id
              $result = mysqli_query($sql_con,"SELECT vote_up,vote_down FROM crewlist WHERE unique_content_id='$unique_content_id' LIMIT 1");
              $row = mysqli_fetch_assoc($result);
  
              //making sure value is not empty.
              $vote_up    = ($row["vote_up"])?$row["vote_up"]:0;
              $vote_down  = ($row["vote_down"])?$row["vote_down"]:0;
  
              //build array for php json
              $send_response = array('vote_up'=&gt;$vote_up, 'vote_down'=&gt;$vote_down);
              echo json_encode($send_response); //display json encoded values
              break;
  
      }
  
  }
  </code></pre>
  
  <p>EDIT: added table rows</p>
  
  <p><a href="https://i.stack.imgur.com/J7nCD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/J7nCD.png" alt="enter image description here"></a></p>
  
  <p>EDIT: please ignore everything, I had syntax error in MySQL table! instead of vote_down I had vote-down and vote_up -vote-down. I have fixed liking system it works, however whenever I click "like" it adds a new row to table. Anyone know why?</p>
  
  <p>Here is my error now!</p>
  
  <p><a href="https://i.stack.imgur.com/dRpxP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dRpxP.png" alt="enter image description here"></a></p>