On Tue, Aug 9, 2011 at 10:14 AM, David Green <simp...@gmail.com> wrote:
> $data = mysql_query("SELECT * FROM news_items WHERE upper('headline') LIKE
> '%$find%'");

A couple things to consider.

First, as a few others have pointed out, you probably want to remove
the single quotes around the word headline in your query. The quotes
cause the query to compare the wildcard string '%{$find}%' to the
literal string 'headline' instead of the contents of a column named
headline. That would cause your query to return either no results for
ordinary search terms, or else return the entire table if the value of
$find is the word 'headline' or any sequence of characters within that

You also probably don't need upper(...) function at all. Unless you
used a case-sensitive collation for that column/table (or are storing
it as binary data rather than text) the condition

'My Article Title' LIKE '%article%'

would return a match even though the case is different.


PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to