hello sir,

please help how to search multiple field i am trying but show this error

Found:
Fatal error: Call to a member function free() on a non-object in G:\WampDeveloper\Websites\DefaultWebsite\webroot\test2\search.php on line 59


My Code:

<?php
/*set varibles from form */
$searchterm = $_POST['searchterm'];
trim ($searchterm);
/*check if search term was entered*/
if (!$searchterm){
echo 'Please enter a search term.';
}
/*add slashes to search term*/
if (!get_magic_quotes_gpc())
{
$searchterm = addslashes($searchterm);
}

/* connects to database */
@ $dbconn = new mysqli('localhost', 'username', 'password', 'database');
if (mysqli_connect_errno())
{
echo 'Error: Could not connect to database. Please try again later.';
exit;
}
/*query the database*/
$query = "select * from splist where partcatno,costprice like '%".$searchterm."%'";
$result = $dbconn->query($query);
/*number of rows found*/
$num_results = $result->num_rows;

echo '<p>Found: '.$num_results.'</p>';
/*loops through results*/
for ($i=0; $i <$num_results; $i++)
{
$num_found = $i + 1;
while ($row = $result->fetch_object())
if ($result->num_rows > 0)
{
echo "<table border='1' cellpadding='10'>";
echo "<tr><th>ID</th><th>Description</th><th>Part/Cat No</th><th>Total Quantity</th><th>Balance</th><th>Cost Price</th><th>Sales Price</th><th>Remarks</th><th></th><th></th></tr>";

{
// set up a row for each record
echo "<tr>";
echo "<td>" . $row->idd . "</td>";
echo "<td>" . $row->despspl . "</td>";
echo "<td>" . $row->partcatno . "</td>";
echo "<td>" . $row->totalquantity . "</td>";
echo "<td>" . $row->balance . "</td>";
echo "<td>" . $row->costprice . "</td>";
echo "<td>" . $row->salesprice . "</td>";
echo "<td>" . $row->remarks . "</td>";
echo "<td><a href='records.php?idd=" . $row->idd . "'>Edit</a></td>";
echo "<td><a href='delete.php?idd=" . $row->idd . "'>Delete</a></td>";
echo "</tr>";
}

echo "</table>";
}
}
/*free database*/
$result->free();
$dbconn->close();
?>