All, I have the following code in php where I want to select data from mysql and put into json_encode. If it contains single quotes etc it fails.
// get the notes if any
$notes = array();
$result = mysqli_query($con, "SELECT id, notes FROM tc_ssa_notes WHERE ssa_id = " . mysqli_real_escape_string($con, $ssa_id));
while ($row = mysqli_fetch_assoc($result))
{
$notes[] = $row;
}
mysqli_free_result($result);
#en: send data packaged in json array
echo json_encode(array('notes' => $notes));
Output of var_dump( $notes );
:
array(4) {
[0] => array(2) {
["id"] => string(2) "26" ["item"] => string(55) "Are electrical panels covered when not being worked on?"
} [1] => array(2) {
["id"] => string(2) "28" ["item"] => string(38) "Are extension cords in good condition?"
} [2] => array(2) {
["id"] => string(2) "27" ["item"] => string(39) "B. Are (GFCI�S) in use (If Applicable)?"
} [3] => array(2) {
["id"] => string(2) "29" ["item"] => string(53) "Is GFCI on the generator operational? (If applicable)"
}
}