|
Posted by Dan on 10/08/05 20:49
Do you want to pass the term directly to mysql from your PHP script? If
yes, then I don't see any problems. For example, the following should work
fine:
$str = "%" . $input . "%s";
.... and then in the query '... LIKE ("' . mysql_escape_string($str) . '")
....'
Bogdan
"b" <b@notvalid.ca> wrote in message news:tgS1f.109324$1i.80036@pd7tw2no...
> Hello,
>
> I am writing a web based contact relationship program in PHP
> and MySql,
> and so far all is well, except passing partial queries based
> on wildcard
> characters. For example, if I search on a term like budget,
> or a partial
> search with bu as the search term, it works well. Budget
> will return all
> records with budget in the requested field and bu will
> return all records
> with bu as any part of the search term. Now, if I do a
> search on Calgary
> or California, or a partial search such as ca, I get a
> strange character
> in the URL instead of the wildcard search.
>
> Here is the code I am using for the wildcard based search:
>
> if(isset($_GET('newWild')) {
> $newWild = "%".$_GET['newWild']."%";
> $wildcard = $newWild;
> } else {
> $newWild = "%".$_POST[''searchTerm'];
> $wildcard = $newWild;
> }
>
> I check to see if newWild is set in the URL for pagination
> purposes or if
> not set, then return the query as posted from a form.
>
> I then surround the search term with %'s to allow for
> wildcard searches
> based on partial searches.
>
> I think that because I am surrounding the search term in
> %'s, PHP is
> interpreting any valid %## combination as hex
> representation, such as %20
> being interpreted as ' space '.
>
> How do I pass the actual value instead of having PHP
> interpret any valid
> %## combination as a hex representation?
>
> For example, a partial search for provinces/states starting
> with cal, is
> supposed to be passed as %cal%, but instead, passes as
> <hex>l% in the URL.
>
> Forgive the <hex> but I can't reproduce the symbol, (it is
> like a capitol
> E with an accent above it).
>
> Thanks!
>
> Oh, the version of PHP I am using is version 4.4
Navigation:
[Reply to this message]
|