Here is what I have so far….

if (@$_POST['search']=="search")
{
@$keywords=split(" ",$_POST['keyword']);

foreach ($keywords As $keyword){

$keyword = get_magic_quotes_gpc() ? addslashes(trim($keyword)) : trim($keyword);

$search[]="itemname LIKE ‘%$keyword%’ OR message1 LIKE ‘%$keyword%’";

}

$search = join("OR ", $search);

$result=mysql_query("SELECT * FROM listed WHERE($search)");
while ($results = mysql_fetch_array($result))
{
$price=$results['price'];
$idno=$results['id'];
$title=$results['itemname'];
$description = $results['message1'];
$position=40;

$post = substr($description, 0, $position);

echo //the rest of the code won’t fit but this is where I echo my results…which works fine.

My search query is having a problem with searches containing symbols, such as ?,."!@#$%^&* I was wondering how I can filter these out using the preg_replace function.

My PHP is very minimal, so over-explaining your answers is greatly appreciated.

Technorati Tags: , , , , ,