OK, I think I've solved this, and you'll probably kick yourself when I explain it!"
But first, a teaser: what looks like a double-quote in HTML, but isn't?
>From: John Taylor-Johnston
> If I run the SQL in PHPMyAdmin, (a MySQL web interface), it works.
> jdaxell.ccl = 2 records found.
> SELECT id,AU,ST,BT,AT FROM ccl_main WHERE MATCH
> AGAINST ('"ready maria"' IN BOOLEAN MODE)
> ORDER BY id asc
> But try to pass it through PHP - zippo. MySQL thinks it is a boolean
> search for
> +ready +maria
> not an exact search for the two words together
> "ready maria"
> MySQL does not see the double quotes. It should. Somehow, PHP is
> thwarting them?
Not PHP, your browser, I suspect. In fact there are no quotes there! No, donm't yell
at me, there really aren't!!
Close inspection of the source of your "non-working" result reveals that what it has
actually searched for is "ready maria" -- which, of course, displays on the
screen as "ready maria", with the HTML " entities converted to double quotes! Of
course, as the $search variable actually contains the version with the "
entities, this is what MySQL sees, and duly regards it as a non-quoted string
contining the words quot, ready and maria, and a few non-significant punctuation marks!
What I think is happening is that your browser is encoding certain characters in the
form field into HTML entities before submitting them -- so to get PHP to see them
correctly, you're going to need to unencode any HTML-entities in the string in your
$search variable. I suggest a quick visit to the manual page for html_entity_decode
(http://www.php.net/html-entity-decode) may be in order (this function is not
available until PHP 4.3.0, but the manual page does give a pre-4.3.0 alternative).
(Of course, don't forget to keep the HTML-entities version for echoing back to your
HTML results page!)
This was a neat one -- hope this analysis helps!
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php