Setting Variable to DB conents which contains quotes



I can get the contents of the my database comments field using PHP.
The comments field may include single or double quotes or other strange
characters.
How do I compensate for these problem characters when I try to set a
JavaScript variable? eg.

<SCRIPT LANGUAGE="JavaScript">
MyComments = "<? PHP result here?>"
</script>

.



Relevant Pages

  • Re: Stuck on Exercise 1
    ... Looks like the type of quotes that some word processors like "Microsoft word" uses... ... characters. ... Perhaps the PHP is doing and error and you have the error display disabled. ...
    (comp.lang.php)
  • Re: Encoding & Decoding text
    ... To set the js variable I used the PHP addslashes function which encodes ... those things know how to handle HTML entities (don't forget to set ... this function turns my original single and double quotes into ... their original characters, then run it through the above function. ...
    (comp.lang.javascript)
  • Re: Stuck on Exercise 1
    ... Looks like the type of quotes that ... characters. ... Perhaps the PHP is doing and error and you have the error display ... Try using .php as the file extension. ...
    (comp.lang.php)
  • Re: Frontpage Changing my PHP code
    ... set your cursor where you want your php block and hit insert/ web ... FrontPage WILL leave it alone. ... > and the spaces in between) and the quotes between my <? ... I have to put spaces between the characters to make it show up ...
    (microsoft.public.frontpage.programming)
  • Re: [PHP] Preventing SQL Injection/ Cross Site Scripting
    ... It's a shame that so many PHP installations have them enabled, and a huge disappointment that PHP is actually distributed with this stuff enabled! ... encoding data for output to an HTML document. ... characters into 5, 6, or 7-byte strings, if you already provided the correct character set in the Content-Type HTTP header. ... For anything that gets written to a database or used for a query, I suggest escaping the data using a function specifically designed for that database. ...
    (php.general)