$search = mysql_escape_string($_POST['search']);
$res = mysql_query("SELECT * FROM posts WHERE MATCH (title,post) AGAINST ('{$search}')") or die(mysql_error());
if (!mysql_num_rows($res)) {
print($sec_top.'<div style="padding: 6px;">No matches found.</div>'.$sec_bot);
}
else {
// print each result
while ($foo = mysql_fetch_array($res)) {
$sdate = str_replace(' ',' ',date($date,$foo['time']));
print($sec_top.$in1.$foo['title'].$in2.$sdate.$in3.$foo['post'].$in4.$sec_bot);
}
}
doh.. The problem was in my table. I had a fulltext for the title and a fulltext for the post, but they weren't joined. >.>
i.e.
FULLTEXT title
FULLTEXT post
instead of
FULLTEXT title,post
Ok, dammit. I know I didn't change anything, but it doesn't work again... I don't get any error messages, but I don't get any results.
The one thing I have done is add a giant post. Maybe 2k characters. *shrugs*
$search = mysql_escape_string($_POST['search']);
$res = mysql_query("SELECT * FROM posts WHERE MATCH (title,post) AGAINST ('{$search}') ORDER BY `time` DESC");
if (!mysql_num_rows($res)) {
print($sec_top.'<div style="padding: 6px;">No matches found.</div>'.$sec_bot);
}
else {
// print matches
}
That's what I thought. But I just get "Unknown column 'searching' in 'where clause'."
For natural-language full-text searches, it is a requirement that the columns named in the MATCH() function be the same columns included in some FULLTEXT index in your table.