Forum Moderators: coopster

Message Too Old, No Replies

Search String Question

search

         

joelwsmith

6:48 pm on Dec 2, 2011 (gmt 0)

10+ Year Member



I've setup a search for products (stock video clips) by either title, keywords or colors. It works great for terms like "blue", "flag" or "christmas" and returns all the results properly.

However, when I search terms like "california" or "texas" (I have state flags in products) it returns 0 results. Funny thing is that I have the state names in both titles (capitalized) and keywords (uncapitalized). I also have a Mexico flag and it will show up when I search "mexico". I'm stumped.

$q = preg_replace('#[^a-z 0-9]#i', '', $_POST['q']);
$sqlCommand = "SELECT * FROM products WHERE title LIKE '%$q%' OR keywords LIKE '%$q%' OR colors LIKE '%$q%'";


I know it's something small I'm missing, but can't seem to figure it out. Any ideas would be appreciated.

Thank you.

enigma1

7:58 pm on Dec 3, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I can't see anything missing, do a print_r after the $q var is assigned to make sure the keyword entered is correct. If it is, check the products table, are the columns populated with the expected values?