0

I have special HTML entities in my text stored in mysql. When I try to read that data returned from mysql into PHP using json_encode, it fails silently. When I use json_encode(array_map('utf8_encode', $row)); it give output as

    ["{\"autoid\":\"2\",\"package_id\":\"a78o5jax32\",\"chapter_title\":\"General Aspects of Surgery\",\"question_text\":\"Capsule Endoscopy-False statement is\",\"explanation\":\"
Capsule\\u00dd Endoscopy is not suitable for patients with strictures.<\\\/p>\",\"reference\":\"Bailey and Love 26th Edition P\\\/205\",\"options\":\"Sedation Not RequiredxxxxxxPainless ProcedurexxxxxxVisualize Entire small BowelxxxxxxSuitable For Patients With Stricture Bowel\",\"answer\":\"3\"}","{\"autoid\":\"3\",\"package_id\":\"a78o5jax33\",\"chapter_title\":\"General Aspects of Surgery\",\"question_text\":\"Physiological changes in laparoscopy include all excep\",\"explanation\":\"• Laparoscopy\\u00de causes increased PCWP, Intra cranial Pressure and decreased Functional Residual capacity after expiration is decreased after laparoscopy gas insuffulation.
• There will be Hypercarbia and acidosis (pH decrease)
\",\"reference\":\"Ref: Schwartz Page 417\\\/ 10th Edition\",\"options\":\"Increases PCWPxxxxxxIncreased ICPxxxxxxDecreased FRCxxxxxxIncreased pH\",\"answer\":\"4\"}"]

which cant be parsed as json.

Please help how can I get special entities sored in mysql text and create json. I will later use that json in jquery ajax.

Special entities are like Ý

raju
  • 6,448
  • 24
  • 80
  • 163
  • for json_encode only utf-8 is allowed. A **real* utf8 which you have to get from database, not some blunt function's output. – Your Common Sense Mar 03 '17 at 14:07
  • Dear I wish I have that much knowledge of PHP+MYSQLi to understand what you say. I am just a ui developer. thanks anyway – raju Mar 03 '17 at 14:16
  • just refer to the linked post, it is pretty clear. Make your database return utf8 without the need of using any additional functions – Your Common Sense Mar 03 '17 at 14:26

0 Answers0