Search database table while inserting search term into separate table

I have a basic search function to search and display a database.

I’d also like to store the search terms in a separate table but the search terms aren’t showing in the new table.

What do I have to do so I can search a table then add the search term to a different table? (same database).

Simple php search

<?php
include('../dbconn.php');

//connect to your database ** EDIT REQUIRED HERE **
mysql_connect("localhost","$username","$password")or die (mysql_error()); //(host, username, password)

//specify database ** EDIT REQUIRED HERE **
mysql_select_db("$database") or die("Unable to select database") ; //select which database we're using


?>

<h3>Your Search Results for '<?PHP echo $_REQUEST['term']; ?>'</h3>
  
 <?PHP
  $term=$_REQUEST['term'];

 
$sql = mysql_query("select * from shop where name like '%$term%' or descrip like '%$term%' ORDER BY buynow ASC");

  while ($row = mysql_fetch_array($sql)){
?>	

<table width="100%" border="0" cellpadding="0" cellspacing="10"><tr>

<td><a href="<?php echo $row['awtrack'] ?>"><img src="<?php echo $row['awThumb'] ?>"/></a></td>
 
<td valign="top">
   <a href="<?php echo $row['awtrack'] ?>"><?php echo $row['name']; ?></a> <br/>
   <span class="descript"><?php echo $row['descrip']; ?></span>
	
</td>
<td width="100" valign="top"> 
   £<?php echo $row['buynow']; ?>
 </td></tr>
 </table>
 <?php   }


?> 

I’ve tried adding


$sql = "INSERT INTO searched (sterm) VALUES ('$term')";

But it’s not being posted to the new table I have set up.

i don’t do php, but don’t you have to execute the $sql query string?

just assigning it doesn’t do anyhting, right?

Thanks r397

I’m not a PHPer too,

it seems I need

mysql_query(“INSERT INTO searched (sterm)
VALUES (‘$term’)”);

replaced with

$sql = mysql_query(“INSERT INTO searched (sterm) VALUES (‘”.$term.”’)”);