Why do escape characters (\) appear in one form field but not another?

I have created a database input form. There are three fields for notes. They were all created at the same time. They have the same logic and class system, but one of them comes back with escape marks when I update the entry, eg. I enter

1
2
3

      

and the updated record returns

1\r\n2\r\n3

      

I am confused as the other returns the text in a formatted way. Can you explain why this is happening?

0


source to share


2 answers


As Konrad suggested ambiguity to your question. Are they both on the same page? If not, make both pages the same DOCTYPE

?

The simplest solution to this is to handle it independently, addslashes

(or mysql_real_escape_string

) for INSERT

and UPDATE

and stripslashes

for SELECT

s.



Another scenario you have to handle is POST

on the error page (for example, filling in post values). You must make sure the value POST

is the "split" version of the forward slashes, otherwise you will double up with addlashes; so it only adds when all your checks and mail checks are complete.

+1


source


As it is, your question does not contain a lot of important information. Obviously, if everything is done the same, the data will be the same. Also, you probably don't mean that there are evacuation marks in your data (or do you?). In this case, you must explicitly call the function to convert line breaks to a string containing '\'

and 'n'

.



Lack of any code, I am assuming you display your data differently; once using normal echo

and once using something like var_dump

.

0


source







All Articles