when i run the following script it returns 0 results from the data base. By accident I duplicated a row in mysql when I query it, it will return both. If I take the duplicate out it returns 0 results. I am learning both php and mysql.

PHP Script
<?php
//Force script errors and warnings to show during production only.
error_reporting(E_ALL);

ini_set('display_errors', '1');

// intialize search_output variable
$search_output = "";

if(isset($_POST['searchquery']) && $_POST['searchquery'] != ""){
// run code if condition meets here
$searchquery = preg_replace('#[^a-z 0-9?!]#i', '', $_POST['searchquery']);


$sqlCommand = "SELECT * FROM search WHERE keywords ='%$searchquery%'";

include_once("connect_to_mysql.php");

$query = mysql_query($sqlCommand) or die(mysql_error());

$count = mysql_num_rows($query);

if($count > 1){

$search_output .= "<hr />$count results for <strong>$searchquery</strong><hr />";

while($row = mysql_fetch_array($query)){

$id = $row["id"];
$keywords = $row["keywords"];
$title = $row["title"];
$link = $row["link"];
$description = $row["description"];

$search_output .= "Item: $title,<br />
Description - $description,<br />
<a href='$link'>$link</a><br /><hr />";

} // close while

} else {

$search_output = "<hr />0 results for <strong>$searchquery</strong><hr />$sqlCommand";

}


}

?>


<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

Search: <input name="searchquery" type="text" size="40" maxlength="88">


<input name="myBtn" type="submit">
</form>


Data base


Host: 127.0.0.1
Database: search_box
Generation Time: Dec 03, 2012 at 09:28 PM
Generated by: phpMyAdmin 3.5.2.2 / MySQL 5.5.27
SQL query: SELECT * FROM `search` LIMIT 0, 30 ;
Rows: 7






id

title

description

keywords

link




1

Paper Rush

Paper rush is used in seat weaving

paper rush, fiber rush, fiber cord

paper_rush.php



4

Flat Reed

Flat reed is used in basket weaving an wicker furniture.

flat reed, flat flat reed, flat rattan core

flat_reed.php



5

Round Reed

round reed is used in wicker furniture and basket weaving.

round reed, center cane, rattan core

round_reed.php



6

Binder Cane

Binder cane is used for wiker furniture wrappings, closewoven seat weaving and the final step of hand cane.

binder cane

binder_cane.php



7

Open Mesh Cane

Open mesh cane is used in seats an backs that have a groove around the frame.

Open mesh cane, machined cane, pressed cane, cane webbing

openmesh_cane.php



8

Reed Spline

Reed spline is used to hold the cane in a groove when using cane webbing

red spline, spline

reed_spline.php



10

Round Reed

Round reed is used in wicker furniture and basket weaving.

round reed, center cane, rattan core

round_reed.php