SharkBait Posted December 11, 2006 Share Posted December 11, 2006 What do I need to use to escape double quotes?The javascript online editor I use needs double quoetes (") escaped with a backslash.Can I [code=php:0]str_replace('"', '\"', $_POST['body'])[/code] or is there something else I need to look at?Would [code=php:0]addslashes()[/code] escape double quotes? I'd also need to replace \n and \r characters with I suppose <br /> instead.Thanks Quote Link to comment Share on other sites More sharing options...
Psycho Posted December 11, 2006 Share Posted December 11, 2006 What you are trying to accomplish is not very clear. Please give an example of what would be in $_POST['body'] and what you want to translate that to. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted December 11, 2006 Share Posted December 11, 2006 add slashes adds slashes to ' and to " maybe this for the second part:preg_replace("~^\n$|^\r$~","I suppose ",$_POST['my_str']); Quote Link to comment Share on other sites More sharing options...
SharkBait Posted December 11, 2006 Author Share Posted December 11, 2006 Ok I gues using $_POST[] wasnt the best example.When I edit my blog entries the javascript editor I use online (FCKeditor) requires that if I have a pre-existing entry in the textarea, that I escape all double quotes and get rid of any \r \n it has in the message.So when I pull the information from the database to be displayed on my editing page I have to make sure that the javascript doesn't freak out.This is the section I am trying to abide by: http://wiki.fckeditor.net/Developer%27s_Guide/Integration/Javascript#line-132the[code]oFCKeditor.value = '{$my_database_entry_text_ here}';[/code] Quote Link to comment Share on other sites More sharing options...
SharkBait Posted December 12, 2006 Author Share Posted December 12, 2006 [quote author=The Little Guy link=topic=118206.msg482920#msg482920 date=1165871698]add slashes adds slashes to ' and to " maybe this for the second part:preg_replace("~^\n$|^\r$~","I suppose ",$_POST['my_str']);[/quote]So something like this?[code]<?php$body = addslashes($entry['body']);preg_replace("~^\n$|^\r$~","<br />", $body);?>[/code] Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted December 12, 2006 Share Posted December 12, 2006 yeah... That should workIf not... Then take out the $ signs and try that Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted December 12, 2006 Share Posted December 12, 2006 can you teach me how to install the javascript online editor please..? ^^ Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted December 12, 2006 Share Posted December 12, 2006 [quote author=ted_chou12 link=topic=118206.msg483446#msg483446 date=1165947240]can you teach me how to install the javascript online editor please..? ^^[/quote]What does that have to do with this topic? Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted December 12, 2006 Share Posted December 12, 2006 I think he means one of the WYSIWYG text editors, such as TinyMCE or FCKeditor. Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted December 12, 2006 Share Posted December 12, 2006 because i am having some trouble installing the online javascript editor into the form... :'( Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted December 12, 2006 Share Posted December 12, 2006 start a new thread. Quote Link to comment Share on other sites More sharing options...
SharkBait Posted December 13, 2006 Author Share Posted December 13, 2006 I tried this and it seemed to work:[code]$body = preg_replace("((\r\n)+)", " ", trim($body));[/code]Though you're code might of worked too, I think i was forgetting to actualyl assign the preg_replace to $body ;)Thanks for the help it works the way I need it to now! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.