I am using a PHP web service to get results from an sql query within one of the tables has quotes and when I use the query below it the result shows this table as null. Now I had this issue already and what I had to do was encode the array then with utf8_encode
. However that doesn't seem to work now. How can I now encode my results to show the table in my json results.
My code is below
$id = 14;
include("file.php");
$query = "SELECT * FROM table WHERE table_id='$id'";
$sth = $dbc->query($query);
$result = $sth->fetchAll();
$result = utf8_encode($result);
/* output in necessary format */
header('Content-type: application/json; charset=utf-8');
echo $_GET['onJSONPLoad'];
echo "(" . json_encode($result) . ")";