Str_replace or escape of special characters in .php

Hi again. The topic this time is str_replace statement used in a .php serving our App to implement a message-like feature through Mysql DB. The issue is that the special character " is not tolerated in the message string, even using str_replace in the .php to replace this character with space or something else causes error and App to crash. NB! all other special characters are handled (we have used str_replace to replace, commas and other characters), but we cannot seem to solve the problem with " character. Any suggestion? We would actually prefere by far a statement like real_escape_string to escape the interpretation of this character as special so it would be handled as literal, but we cannot seem to find a real_escape_string statement other than associated with Mysql (mysqli_real_escape_string).
Any suggestion?
Thank you!

What do the PHP communities have to say about replacing a single double quote in a string?

('"Lewis "Junior" is here"')

Change the double quote for a character before sending it: Lewis |Junior| is here

Try Lewis "Junior" is here

1 Like

Hi and thanks for the suggestion which worked just fine for the " character. But the same problem occurs for the following characters: # & ' +. We find it very strange that there is not a general way to escape the annotation significance of these characters making them only literal like any other character.
W appreciate any suggestion/help.

This is the App Inventor community
For questions about php please ask in a php community or at


How do you send the information to MySQL?, do you use Web1.UriEncode?


No, build web.url with a Join containing url, and variables to pass to the .php that inserts into DB. And then a call to Web.Get.

Thank you! Using UriEncode solved all characters, except the ". This we solved with replace. Thanks!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.