php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #362 simple and double quotation mark
Submitted: 1998-05-08 07:36 UTC Modified: 1998-05-08 08:36 UTC
From: fer at fert dot es Assigned:
Status: Closed Package: mSQL related
PHP Version: 3.0 Release Candidate 4 OS: linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: fer at fert dot es
New email:
PHP Version: OS:

 

 [1998-05-08 07:36 UTC] fer at fert dot es
in a where clause you cannot use a variable containig simple
 or double quotation marks. However, if that variable comes
from a form, it works!
By the moment, we have solved the problem using a reg_replace
function changing ' with \', that is, escaping these naughty
characters.



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-05-08 08:36 UTC] zeev
This is not a bug in PHP, but a bug in the script...
The query that you're forming inside the double quotes
simply isn't a valid SQL query.
The reason it works with variables that come from forms,
is that you probably have magic_quotes_gpc turned on,
and magic_quotes_gpc automatically escapes any input
coming from GET/POST/Cookie variables, so no further
escaping is required.

To avoid the problem, you should run addslashes() on
the string before putting it into the query text, e.g.
$foo = addslashes($foo);

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 21:01:36 2024 UTC