php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24383 Differences between string escaping
Submitted: 2003-06-29 08:01 UTC Modified: 2003-06-29 08:49 UTC
From: baglan at ankara dot edu dot tr Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.3.1 OS: Win32/Linux/OpenBSD
Private report: No CVE-ID: None
 [2003-06-29 08:01 UTC] baglan at ankara dot edu dot tr
Description:
------------
I write and test PHP scripts on WinXP with Apache 1.3.x and pre-compiled PHP 4.3.2. Sites where I host my pages are Linux and OpenBSD running Apache 1.3.x and PHP 4.3.1. In both cases I use MySQL. Both PHP installations have the same configuration except for the file paths.

Program I wrote stores HTML pages in database so the text in SQL statement has to be escaped. Under WinXP I have to write code like this:

$string = "'".addslashes($string)."'";

Under Linux and OpenBSD installations when I run the same code I get the string escaped TWICE. I presume that the string is escaped again during concantenation.

Reproduce code:
---------------
$string = '<IMG SRC="http://example.com/Arrow.gif">';
$string = "'".addslashes($string)."'";

// Under WinXP I get:
// <IMG SRC=\"http://example.com/Arrow.gif\">

// Under Linux & OpenBSD I get
// <IMG SRC=\\\"http://example.com/Arrow.gif\\\">


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-06-29 08:27 UTC] marcot at tabini dot ca
Works fine on my Linux system. You probably have magic_quotes_runtime on, and the string is escaped twice.
 [2003-06-29 08:49 UTC] derick@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

See comment by Marco
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jul 06 09:01:29 2024 UTC