2

So normally I am not a big fan of text editors, but I am making some forums for a client and I am having a huge issue with it.

I did not have this issue in Xampp but now that it is live it's going to have a ton of issues.

Instead of wrapping the inserted text with <p></p> as it does in Xampp it simply inserts plain text with \r\n in place of <br /> at first I thought it was the way it was set up, but I changed it to not force <p> but to force <br />. Not the issue.

I have the following line of code now to try to fix the issue and just convert it to normal line breaks but it is not working.

$string = nl2br(html_entity_decode(htmlentities($topic_info['topic_message'], ENT_QUOTES, 'UTF-8')));

I have tried several different variations, and have tried just nl2br by itself without all the other mess, but nothing it is still showing \r\n instead, he is a sample line. why arent you flippin working\r\njebus &nbsp; how can I either fix it to show the line without the \r\n or how can I fix it to actually insert the text from the text editor right.

kira423
  • 325
  • 1
  • 5
  • 26
  • It is not clear from your question where the difference comes into play. Maybe just the tinymce editor has been deactivated? – hakre Dec 16 '12 at 08:13
  • No the tinymce editor is working, when I test it out it inserts the text as I showed above in that manner using `\r\n` instead of `
    ` and `nl2br` isn't working to fix it
    – kira423 Dec 16 '12 at 08:19
  • check the tinymce configuration then. you should normalize line-ending characters across platforms. Search for that problem with TinyMCE specifically. – hakre Dec 16 '12 at 08:21
  • the configuration is right, like i said it worked just fine in Xampp but when I moved it to a live host it isn't working, of course the php versions are different, but that shouldn't make a difference when it comes to these functions – kira423 Dec 16 '12 at 08:29
  • There is a difference between guessing and knowing. As you're debugging, only relate to facts. Facts are things you have got proven in the new situation. Normally problems after moving to new systems are 99.9% of the time a configuration issue. Just BTW FYI. – hakre Dec 16 '12 at 08:31
  • I have checked and recheked the configuration, if it is loading the text editor then the configuration is right, its the communication between the text editor and the database that is getting jumbled – kira423 Dec 16 '12 at 08:39
  • Are you pre-filling the editor with data? If yes, which line-endings are you using for the pre-fill value? – hakre Dec 16 '12 at 08:40
  • No i am not there is no prefilled data just all new text – kira423 Dec 16 '12 at 08:42
  • What are your TinyMCE settings for the end-of-line character and the related options then? – hakre Dec 16 '12 at 08:45
  • @kira423 We need more info. As @hakre said above, please post your TinyMCE settings, a `var_dump` of `$topic_info['topic_message']` and `$string` (not a copy from the db, a proper var_dump on the page) and the code snippet where you set your text on the page for TinyMCE. – Tanzeel Kazi Dec 16 '12 at 09:43
  • Next to var_dump also consider a [hex-dump of the string](http://stackoverflow.com/q/1057572/367456). – hakre Dec 16 '12 at 09:44

1 Answers1

1

Try stripping the slashes. Maybe your string is getting double escaped.

$string = nl2br(stripcslashes(html_entity_decode(htmlentities($topic_info['topic_message'], ENT_QUOTES, 'UTF-8'))));
Tanzeel Kazi
  • 3,797
  • 1
  • 17
  • 22
  • there are no slashes besides the \r\n no extra in the database so there isn't any to strip – kira423 Dec 16 '12 at 08:42
  • Why the downvote? @kira423 Can you do a `var_dump($topic_info['topic_message']);` and post it in your question. – Tanzeel Kazi Dec 16 '12 at 09:00
  • I already did `why arent you flippin working\r\njebus  ` is exactly copy and pasted out of the database not the page. and I am not the one that downvoted you – kira423 Dec 16 '12 at 09:07
  • @kira423 I didn't point at you. I mentioned you after the downvote comment. Peace. – Tanzeel Kazi Dec 16 '12 at 09:44
  • I've faced the same problem, but with `VbScript`. Just replaced `VbCrLf` and everything worked fine. – Roger Ramos Jul 08 '16 at 13:45