Friends, if I edit my articles, always appear like this "\\r\\n". How to remove it? I use "stripslashes" but does not function properly. Help me, friends.
Emm using @TimK's code, I think this might be easier, plus you'll what the returns and next line codes replaced with <br /> so try this instead. $newString = preg_replace("#\\\\r\\\\n#", "<br />", $string); PHP:
I think stripslashes() is the right way to avoid this. if you want my help put your code here, i will try once.
How to insert the code above?? Sorry friends, I still do not understand. To save the articles to the database, I have a code like this: function antislashes($data){ $anti = stripslashes($data); return $anti; } $content = antislashes($_POST[text_area]); PHP: Thanks advance, friends.
Is this something you added because of the \\r\\n problem ? function antislashes($data){ $anti = stripslashes($data); return $anti; } $content = antislashes($_POST[text_area]); PHP: What is the normal method for displaying the content/articles, is echo $data or $content ?
\\r\\n suddenly appears when I edit articles, and in the database \\r\\n stored as text. ex: The\\r\\n visitor/candidate registration enables attending visitors and \\r\\ncandidates to register their career, employment, education, and training\\r\\n aspirations. They only have to log in to the link, NCEE 2011 Visitor /\\r\\n Candidate Registration, and complete the registration form. This is my code: function antislashes($data){ $anti = stripslashes($data); return $anti; } $content = antislashes($_POST[text_area]); mysql_query("UPDATE article SET tab_article = '$content' WHERE id_article = '$_POST[id]'"); PHP: Method for displaying the content / articles is: $article = nl2br ($a[tab_article]); echo "$article"; PHP: Do I have to replace as below, to remove \\r\\n and it will never comes back: function antislashes($data){ $anti = preg_replace("#\\\\r\\\\n#", "", $data); return $anti; } $content = antislashes($_POST[text_area]); mysql_query("UPDATE article SET tab_article = '$content' WHERE id_article = '$_POST[id]'"); PHP:
Yes, you replaced that correctly fixesign. However, I strongly recommend you to escape all data you're using in your query, as this is a huge security risk your taking. I'd suggest you escape the ID and content. Please refer to this page for more information: http://php.net/manual/en/function.mysql-real-escape-string.php
When I tried the offline mode, it works very well. But when online, the code above is really not able to function so that \\r\\n is still stored in the database. Is something wrong? Help me, friends....