title: Echoed strings are not always displaying single Quotation marks
body: <p>I have a website (<a href="https://www.talkanxiety.com" rel="nofollow noreferrer">link</a>) where user stories are shown on screen taken from a MySql database. My issue is that apostrophes are not always shown in the end presented data. I use <code>htmlentities($row['MessageText'],ENT_COMPAT|ENT_IGNORE, &quot;UTF-8&quot;)</code> and then <code>echo json_encode($data)</code>.</p>
  <p>The below example comes out without the apostrophes (So it's is its and I'm is Im):</p>
  <blockquote>
  <p>Sounds crazy, but it’s everything; home, work, what people think of me. If I sit still its worse, that’s why I’m always busy</p>
  </blockquote>
  <p>var_dump:</p>
  <pre><code>array(5) { [&quot;ID&quot;]=&gt; int(65) [&quot;UserIDLikeChk&quot;]=&gt; string(1) &quot;0&quot; [&quot;MessageText&quot;]=&gt; string(1263) &quot;Sounds crazy, but it�s everything; home, work, what people think of me. If I sit still its worse, that�s why I�m always busy, always moving. Its things in my head that are out of my control. I can but quite irrational, like the worst thing is going to happen and it gets worse when I�m tired. When I�m exhausted I get irrational. When I was young I got panic attacks. I can control them now, but when I came back from Orlando recently, I was very tired and I could feel I was spiralling down a bit, like a panic attack was coming. When that happens all I can see is what is in my head and no one can talk sense to me. I can have a period of a couple of weeks, where I can feel the anxiety underlying, a knot in my stomach and I know if I�m not careful I could have a panic attack. I�m not a very confident person, so that makes the worry worse I think. I try to rationalise things and that makes things better. I use the Calm app, I speak to my mum, I remove myself from people and that calms me down. I also go to the gym to get the kick from the endorphins. I also avoid alcohol now because that makes things much worse. I think I was drinking after the Orlando trip, when I was really tired, I had a heavy night when I went out, and that made it so much worse.&quot; [&quot;CntLikes&quot;]=&gt; int(0) [&quot;Type&quot;]=&gt; int(0) }
  </code></pre>
  <p>Code:</p>
  <pre><code>$userid = session_id();
  $stmt = $con-&gt;prepare(
  
              'SELECT
                a.ID, ? as UserID, IFNULL(b.UserID,0) as UserIDLikeChk, a.MessageText, a.CntLikes, IFNULL(b.Type,0) as Type
              FROM
                (
                   SELECT m.ID, m.MessageText,count(l.ID) as CntLikes
                   FROM MessageMain m 
                   LEFT OUTER JOIN Likes l ON m.ID = l.PostID
                   WHERE Valid = 1
                   GROUP BY m.ID, m.MessageText ORDER BY RAND() LIMIT 10
                )a
  
              LEFT OUTER JOIN
  
               (
                 SELECT PostID, UserID, COUNT(*) AS Type 
                 FROM Likes 
                 WHERE UserID = ?
                 GROUP BY PostID, UserID
                )b
  
              ON a.ID = b.PostID'
        );
  
        $stmt-&gt;bind_param('ss', $userid, $userid);
        $stmt-&gt;execute();
        $result = $stmt-&gt;get_result();
  
        $data = array();
  
       if(mysqli_num_rows($result) &gt; 0) {
  
          While($row = $result-&gt;fetch_assoc()) {   
  
          $data[] = array ( 
              'ID' =&gt; $row['ID'],
              'UserID' =&gt; $row['UserID'],
              'UserIDLikeChk' =&gt; $row['UserIDLikeChk'], 
              'MessageText' =&gt; nl2br(htmlentities($row['MessageText'],ENT_COMPAT|ENT_IGNORE, &quot;UTF-8&quot;) ), 
              'CntLikes' =&gt; $row['CntLikes'],
              'Type' =&gt; $row['Type'] 
          );
  
        }
      }
          echo json_encode($data);
  </code></pre>