php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #75755 MySQLi should provide an escape function for use in MATCH...AGAINST
Submitted: 2018-01-03 16:41 UTC Modified: 2018-01-03 16:46 UTC
From: php4fan at gmail dot com Assigned:
Status: Open Package: MySQLi related
PHP Version: 7.1.12 OS:
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 — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
2 + 42 = ?
Subscribe to this entry?

 
 [2018-01-03 16:41 UTC] php4fan at gmail dot com
Description:
------------
Say you have a string $someword and you need to use it within a query like:

"SELECT whatever where MATCH(whatever) AGAINST('+$someword +someotherword' IN BOOLEAN MODE)"

You need to properly escape certain characters in $someword so that you don't get syntax errors in the boolean search expression. I know I'm being sloppy at defining what needs to be done. Actually I'm pretty sure there are different kinds of escaping you would need for different use cases, but it's certainly possible to define them unambiguously.

Expected: there should be methods in the MySQLi class for this.

Observed: you have to write your own code, and you'll almost certainly get it wrong; or you'll have to find some 3rd party libraries, which is pathetic.



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-01-03 16:46 UTC] nikic@php.net
-Summary: MySQLi MUST provide an escape function for use in MATCH...AGAINST +Summary: MySQLi should provide an escape function for use in MATCH...AGAINST -Type: Bug +Type: Feature/Change Request -PHP Version: 5.6.32 +PHP Version: 7.1.12
 [2018-01-03 16:46 UTC] spam2 at rhsoft dot net
http://php.net/manual/en/mysqli.real-escape-string.php
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 19:01:28 2024 UTC