FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » store backslash in mysql database
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: store backslash in mysql database [message #170651 is a reply to message #170645] Sat, 13 November 2010 08:41 Go to previous messageGo to previous message
Helmut Chang is currently offline  Helmut Chang
Messages: 22
Registered: September 2010
Karma:
Junior Member
Am 13.11.2010 04:28, schrieb Jerry Stuckle:

> mysql_real_escape_string() won't change backslashes.

Of course it does. It's exactly, what this function is for:

<http://www.php.net/manual/en/function.mysql-real-escape-string.php>

| mysql_real_escape_string() calls MySQL's library function
| mysql_real_escape_string, which prepends backslashes to the following
| characters: \x00, \n, \r, \, ', " and \x1a.

> It has no way to
> know if, for instance, "\n" is a newline character or a backslash and an
> n.

Yes, it has. Because PHP has this ability:

'\n' is a string, containing a backslash and an n
"\n" is a string, containing only a newline character

<?php
$db = mysql_connect('localhost', ..., ...);

$data = 'CÊ=3Fa=3F³Ýöâ8T\TBÆ';
var_dump(mysql_real_escape_string($data, $db));

$data = "Foo\nBar";
var_dump(mysql_real_escape_string($data, $db));

$data = 'Foo\nBar';
var_dump(mysql_real_escape_string($data, $db));
?>

Helmut
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: website url as input how to create and save image on server in php?
Next Topic: Cannot write utf8 data into a utf8 column
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 01:04:49 GMT 2024

Total time taken to generate the page: 0.04341 seconds