jt Posted May 15, 2008 Share Posted May 15, 2008 I have a form that includes a text area. When I insert the value of the text area into MS SQL, it places \r\n etc wherever the user wanted a new line or paragraph. So for example, in the form, my text looks like this: test testtest test in the column in SQL Server, my inserted value looks like: test\r\n\r\ntesttest\r\n\r\ntest etc I need this to insert into SQL server, without those values (basically, I just want to insert exactly as it looks on the textfield when the user fills it in). In MySQL, I have no problem with this since it seems to insert normally (although I think PHPMyAdmin might format those fields with nl2br() automatically, not sure about that). Then, when I display these from a SELECT on my site, I need to be able to use the nl2br() function normally so that the text gets formatted for display. I tried using a couple different forms of preg_replace(), but can't seem to get that right, not does str_replace() seem to do what I want. I've searched and searched for something on this, and can't seem to get what I'm looking for. Any thoughts would be much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/105813-mssql-nr/ Share on other sites More sharing options...
jt Posted May 16, 2008 Author Share Posted May 16, 2008 Nevermind, I was passing the string through a deprecated custom function that was using the function mysql_real_escape_string() before it was being inserted. Removing this and using a stripslashes() on the string before insert works the way I intend. Quote Link to comment https://forums.phpfreaks.com/topic/105813-mssql-nr/#findComment-542902 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.