Ummm...if you really wanted to
set $text = "he talks too much, and never shuts up." and have a prank in my database with the text, 'shuts'
and find a match, then you have your LIKE backwards.
YOu would have to do:
SELECT * FROM pranks WHERE '$text' LIKE CONCAT('%',pranksentry,'%') ORDER BY id
The wildcards only work ONE WAY. Same as when you use a "ls" command to list a directory.
If you do
you'll get files named "food" and "afoolish" and "xyfoo".
But if you do
you won't get "afoolyish" or "xyfoo".
Think of it this way: a LIKE b
means "search for b inside of a" with the special provision that if b contains a % character then the % matches ANY characters in a. When you do
WHERE 'talks' LIKE '%he talks too much%'
then the %'s don't really matter, because obviously b is longer than a and so "search for b inside a" could not possibly work.