|  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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
45 - 13 = ?
Subscribe to this entry?

 [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


Add a Patch

Pull Requests

Add a Pull Request


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-2022 The PHP Group
All rights reserved.
Last updated: Sat Jan 22 18:03:35 2022 UTC