A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2008 yearWhy are escape characters (\) appearing in one form field but not in another? - page 1
User InfoPosts
Why are escape characters (\) appearing in one form field but not in another?#1
I've been building a database input form. There are three fields for notes. They were all build at the same time. They have the same logic & class system - but one of them is returning with escape marks when I update the record, e.g. I enter

1
2
3


and the updated record returns

1\r\n2\r\n3


I'm confused as the other return the text as formatted. Can you sugggest why this is happening?

posted date: 2008-12-18 10:15:00


Re: Why are escape characters (\) appearing in one form field but not in another?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2008-12-18 10:15:01


Re: Why are escape characters (\) appearing in one form field but not in another?#3
As it is, your question lacks a lot of crucial information. Obviously, if everything is done identically, the data will be the same as well. Additionally, you probably don't mean that there are escape marks in your data (or do you?). In that case, you must have explicitly called a function to convert line breaks into a string containing the characters '\' and 'n'.Lacking any code, I assume that you display your data differently; once using a normal echo and once using something like var_dump.

posted date: 2008-12-18 10:20:00


Re: Why are escape characters (\) appearing in one form field but not in another?#4
When you say you have 3 fields for notes, are they all HTML <textarea> tags? Or are two of them HTML <input type="text"> and the one you are having trouble with is a <textarea> tag?

posted date: 2008-12-18 11:10:00


Re: Why are escape characters (\) appearing in one form field but not in another?#5
As Konrad suggested your question lacks clarity. Are they both on the same page? If not, do both pages have the same DOCTYPE?The simplest solution to this is to handle it regardless, addslashes (or mysql_real_escape_string) for INSERTs and UPDATEs and stripslashes for SELECTs.The other scenario you have to handle is a POST to a page that has errors (e.g repopulated with post values). You must make sure that the POST value is the 'stripped' version of the slashes else you will double up on the addslashes; so only addslashes when all your post validation and verification has been completed.

posted date: 2008-12-19 04:34:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.