Re: variable within regular expression
| From: | Jason Wong | Date: | Wed, 09 Apr 2003 07:17:57 +0000 |
| Subject: | Re: variable within regular expression | ||
| References: | 1 2 3 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-26948@lists.php.net to get a copy of this message | ||
On Tuesday 08 April 2003 05:30, Robbie Staufer wrote:
> Thanks for all your suggestions. I've tried them all and am still
> having no luck. It may be the combination of how I'm using the
> conversion statement and the query statement. I've been checking
> through books and on the web and am not finding much about how to use
> REGEXP in a query, where the value of the expression is taken from user
> input and stored in a variable. (I'm thinking it should be exactly as
> Ignatius says....) Here's what I have now;
>
> // user enters a partial expression in the $con form field, and php
> converts the
> // input to a regular expression before searching the database for
> matches
How exactly is this conversion being done? I can't see any conversion.
> //convert $con to regular expression
> // $con = "%$con%";
> $query = "SELECT {$field} FROM {$table} WHERE {$variable} REGEXP '{$con}'
> ";
>
> The results page from this search shows no matches.
I'm assuming you're using MySQL. Does the above query match anything when run
from the mysql commandline?
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
------------------------------------------
/*
The greatest dangers to liberty lurk in insidious encroachment by men
of zeal, well-meaning but without understanding.
-- Justice Louis D. Brandeis
*/