title: PHP json_encode data with double quotes
body: <p>I'm using this simple code to transform database query results into JSON format:</p>
  
  <pre><code>$result = $mysqli-&gt;query("
      SELECT  
          date as a 
          , sum(sales) as b
          , product as c
      FROM  
          default_dataset
      GROUP BY
          date
          , product
      ORDER BY
          date        
  ");
  
  $data = $result-&gt;fetch_all(MYSQLI_ASSOC);
  
  echo stripslashes(json_encode($data));
  </code></pre>
  
  <p>The problem is that if there are double quotes in the data (e.g. in the product column) returned by this query. The json_encode function does not encode the data in a good JSON format.</p>
  
  <p>Could someone help me how to escape the double quotes that are returned by the query? Thank you.</p>