php.net |  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
Description:
------------
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:
---------------
<?php
// 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 
 
feeds

(there are linefeeds as you can see)

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


Patches

Pull Requests

History

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

stripslashes unquotes a string which was quoted with 
addslahes not with mysql_escape_string. 
 
Please reread documentation at http://www.php.net/manual/
en/function.stripslashes.php 
 
 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC