FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


escaping a string - mysql_escape_string





deathseaker
What does it mean to escape a string? :s just wondering.. always see this places..
MrBlueSky
Some characters have special meaning in a string. If you want to use them the 'normal' way, you'll have to escape them by putting a backslash (\) before them.

Example 1:

In strings between " the " has a special meaning: it is the end-of-string delimiter. So this doesn't work:

echo "this is a string: "string"";

You have to escape the ":

echo "this is a string: \"string\"";

(You can also use ' instead of ")

Example 2:

Between double quoted strings \n means a newline. If you don't want to print a newline, but simply \n, you have to escape it:

echo "\\n prints a new\nline";

this prints:


\n prints a new
line


Example 3:

echo "$abc";

means: print the value of variable $abc.

echo "\$abc";

means: print $abc

In general: escaping a string means: escaping all the characters in the string which have a special meaning by putting a backslash in front of them.

mysql_escape_string() escapes all characters which have special meaning to MySQL.
Related topics
MySQL DB Backup script - minor problem
writing COM components in Perl
An Example to mySQL class
C++ Assignment! its about string.h
Disabling "This is a string with a $var"?
Black Holes Actually Green
.html using header/footer include script?
Is this code safe, or not?
string's theory!!
replace a string for a position of text
Can You Get HTML in Your PHP Mail Script?
Replacement of hexadecimal values in PHP string
String theory
Question about safe input from text boxes
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.