This is a discussion on Set JavaScript variable to DB contents within the PHP Language forums, part of the PHP Programming Forums category; Not sure if this post belogs here, but I'm hoping someone can help me out. I can get the ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Not sure if this post belogs here, but I'm hoping someone can help me
out. 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> |
|
|||
|
FP wrote:
> Not sure if this post belogs here, but I'm hoping someone can help me > out. > 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> addslashes() Or maybe htmlentities() is a better choice here. Grtz, -- Rik Wasmus |
|
|||
|
*** FP escribió/wrote (4 Jul 2006 12:08:07 -0700):
> 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> Check the latest user note in: http://www.php.net/htmlspecialchars I don't really understand the code, anyway. You'll probably have enough with: http://www.php.net/addslashes -- -+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain ++ Mi sitio sobre programación web: http://bits.demogracia.com +- Mi web de humor con rayos UVA: http://www.demogracia.com -- |