php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12083 addslashes
Submitted: 2001-07-12 02:41 UTC Modified: 2001-10-20 05:48 UTC
From: xyrix at pisem dot net Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.0.5 OS: Win32
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: xyrix at pisem dot net
New email:
PHP Version: OS:

 

 [2001-07-12 02:41 UTC] xyrix at pisem dot net
addslashes() don't properly work.
Before use it, need add this:
       $str_any=str_replace("\\","\\\\",$str_any);
and only then:
       $str_any=addslashes($str_any);

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-07-12 03:05 UTC] derick@php.net
Please post a short example to show what goes wrong and why.

Derick
 [2001-07-13 00:46 UTC] xyrix at pisem dot net
$image_file=fopen($HTTP_POST_FILES['imagefile']['tmp_name'],"rb");
unset($upload);
while(!feof($image_file)) $upload.=fread($image_file,65535);
fclose($image_file);
$upload=str_replace("\\","\\\\",$upload);
$upload=addslashes($upload);
$query_str="INSERT INTO images (id, image_type, image) VALUES('', '".$HTTP_POST_FILES['imagefile']['type']."', '$upload')";
$insert=mysql_query($query_str, $link);

Function addslashes don't add slashes '\' before '\', and result is corrupt image.
 [2001-10-20 05:48 UTC] sander@php.net
addslashes() works fine for me on binary data...
Unlikely to be a bug: ask support questions on the appropriate mailinglist (see http://www.php.net/support.php).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 11:01:30 2024 UTC