|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27682 bug with mysql_escape_string and linefeeds
Submitted: 2004-03-24 17:52 UTC Modified: 2004-03-25 01:21 UTC
From: ckrack at i-z dot de Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.3.4 OS: Windows NT 5.0 build 219 (win2k)
Private report: No CVE-ID: None
 [2004-03-24 17:52 UTC] ckrack at i-z dot de
I'm experiencing a problem when saving data in db.
i use mysql_escape_string() to escape the string for safe db storage.
when i use stripslashes() to remove the slashes, and then nl2br(), my linebreaks don't get converted to <br /> 's.

this is due to stripslashes().

Reproduce code:
// error
$str = "string with specialchars fo'o'bar's and line \r\n \nfeeds";
$str = mysql_escape_string($str);
$str = stripslashes($str);
echo $str;

Expected result:
string with specialchars fo'o'bar's and line 

(there are linefeeds as you can see)

Actual result:
string with specialchars fo'o'bar's and line rn nfeeds


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-25 01:21 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

stripslashes unquotes a string which was quoted with 
addslahes not with mysql_escape_string. 
Please reread documentation at
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Aug 07 22:01:24 2020 UTC