Form multiplies Inline
I've bumped into a small problem that i cant seem to find the fix for.
I've got this simple form with a textarea, no biggie. The problem shows when i edit a post i've already got in the database.
So, i retrieve the varchar field i have in my database and inserts it into my form by default. If this is what i got by default:
this is some default text
with a line break
now, if i just saves this without doing any changes, this is what i get in the PHP $_POST variable:
this is some default text
with a line break
the /n character seem to multiply by itself. The next time i save the text the /n multiply again, giving me 4 /n in a row and so on.
It doesn't make any sense to me.
Step 1. I pre-fill the textarea with the contents mentioned in the first g开发者_如何学运维ray box above
Step 2. I submit the same content
Step 3. I run the following code before i do anything else:
echo '<pre>'. $_POST['content'] .'</pre>'; die;
Step 4. The newline are multiplied as in the second gray box above
That's easy.
there is some code in your application, that doubles line breaks. Just find it and get rid of it. Not a big deal.
(If you don't trust me, as you obviously do, create a simple testing script consists of just form and nothing else and see)
Wild guess: Windows CR LF
line breaks.
In Windows, if you type a line break, they consist of not only \n
, but \r\n
. If MySQL implicitly converts \r
to \n
when inserting/updating, this would explain this behaviour.
Try removing any occurences of \r
in the PHP first and see if that helps.
Remove line break using trim
精彩评论