December 14th, 2012, 02:36 PM
on my website I have products and in the product description I am getting \n\r showing after each line where as it should be hiding it for example see below
16 ml in each bottle\r\nLuxury Style Bottles\r\nAvailable in White, Clear, Peach, Purple, Red, Pink and Black
it should be like below
16 ml in each bottle
Luxury Style Bottles
Available in White, Clear, Peach, Purple, Red, Pink and Black
Any ideas as not sure if it is the php file or the database causing the issue
to see the issue go here - http://www.worldofcosmetics.co.uk/pr...roducts_id=169
Thank you in advance
December 14th, 2012, 02:51 PM
If you look at the source you will see you actually have a double backslash. That means the \\r\\n is escaped and taken as a literal. In any case that will not render correctly in HTML. If you query the database do those characters show up there? In any case you can get rid of them by running the string through preg_replace. Something like:
Note the use of single quotes to prevent the backslashes from being used as escape characters.
There are 10 kinds of people in the world. Those that understand binary and those that don't.
December 14th, 2012, 02:54 PM
Hi gw1500se thank you so much for the reply
When I looked in the database for the new item I added that has the \n\r after each line, it does show in the database
so is it best to run preg_replace('/\\r\\n//',$string); in the database or is it in a php file
December 14th, 2012, 03:22 PM
something caused these messed up control sequences, so you should first look for the source of the problem. I guess it's some home-made newline conversion function that uses the string "\\r\\n" instead of "\r\n". Just follow the process of how the original text input is saved into the database.
When you've corrected the code, you have to repair your database with the replace function.