Solved

real_escape_string Usage

Posted on 2016-11-15
3
18 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

747 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

15 Experts available now in Live!

Get 1:1 Help Now