Solved

real_escape_string Usage

Posted on 2016-11-15
3
22 Views
1 Endorsement
Last Modified: 2016-11-18
I use   $data = $mysqli->real_escape_string($data);
But the output has /r/n

Should i store it into my database like this?
What do you suggest i should do?
1
Comment
Question by:Braveheartli
3 Comments
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 250 total points
ID: 41887646
The output probably has backslashes like this: \r\n.  These are end-of-line ("EOL") characters, roughly termed "carriage return" and "new line."  They probably come from a PC file or document, since Unix uses only one EOL, the \n.

You should store them if they are meaningful in the context of the data and if your application needs them.  Otherwise you can trim() them off.  It is possible to remove them from the interior of a data string, but it's a little more involved, and it's less likely that you would want to make a change in the middle of a data string.

These EOL characters interact with real_escape_string() functions because they contain backslashes that have programmatic meaning (just like escaped apostrophes).  The MySQLi engine strips backslashes automatically, with the understanding that it expects to receive escaped data, and store exact representations of the data.
0
 
LVL 9

Assisted Solution

by:Moussa Mokhtari
Moussa Mokhtari earned 250 total points
ID: 41887656
Aside from whether you should store it to your database or not its perfectly save to store any values that real_escape_string returns
 \r\n is a way of terminating ASCII line (End Of line in windows) ,You can store it to your database and have no concerns
1

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP_POST() error message 9 45
.php tree directory? 5 57
What is the best PDF generator to use? 1 31
is this a cms? 8 36
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now