Forum
PHP_EOL appearing within TEXT BLOCK as '\n'
I have been using Perch for years and just recently, I had a website working perfectly on my local machine, but when I uploaded it to the target domain, every TEXT BLOCK which has multiple paragraphs, is showing \n characters in between the </p> and <p>.
I guess these \n pairs are PHP_EOL which is output by perch. I dont understand why the browser is treating them as displayable text.
Any ideas/suggestions would be appreciated.
My local PHP files are UTF-8 with unix line feeds and my Perch is 2.8.32 & PHP 5.6.29 My online Perch is 2.8.32 and PHP is 7.0.20
Is this content that you've edited on the live site, or just content you've transferred from local?
Hi, It was edited on the local server using Perch, then transferred to the live site using a SQL dump from phpmyadmin. I have done this many times without problem. I also transfer the entire perch folder too of course.
I have now got around the problem by deleting the regions on the live site, recreating them and pasting the text blocks back in.
I also transferred the live database back to my local server and it is OK.
But I am worried that at some point I will need to transfer from local to live again. I do small edits via perch on local and live sites independently. But when there's major website changes, I need to work locally first.
I think the most likely point where the issue could be introduced is the import/export procedure. This isn't typically something that Perch does to itself.
Hi Drew,
Just for the record, I now have a major website update to do, so downloading and uploading the perch database is now necessary, But I discovered that you were right. There is an sql file incompatibility between the phpmyadmin on my local machine and the server provided by my hosting service. My hosting providers phpmyadmin inserts \n as a new line in the sql file, which is cool. But phpmyadmin on my local server inserts \n. So the escape is escaped and not surprisingly the \n characters get inserted into the tables as text instead of being converted.
I think your last comment, sparked the idea off and when I edited the sql file using gedit (on fedora linux), I saw the extra \ characters. To fix the sql file, I had to replace all \n with \n, but of course, the gedit program recognises the escape character and so I had to type \\n and \n as the find and replace strings.
I think I will switch careers. I fancy basket weaving.
Many thanks. David