php未定义变量 - 不确定是否与sql-query有关[关闭]

what is wrong with query?

$sql="select * from cars where make LIKE '%$term%' AND town LIKE '$town' AND colour LIKE '$colour' AND Reg LIKE '$Reg' AND price > $price AND miles > $miles LIMIT $offset";

echo "<br>";



if (isset($_session['term']))$_session['term']="%";



echo "<br>";


$term=mysql_query($sql,$odbc) or die("Can not run query");

if(mysql_num_rows($term)==0)
{
    echo "no records returned";
}
else
{
    $recCount=mysql_num_rows($term);



    echo"<table>";
        echo"<tr >";
            echo"<td width=130 valign=top> <h4>Search Return:</h4></td>"; 
            echo"<td valign=top>$recCount</td>" ; 
            echo"<td width=150 valign=top> records are found.</td>";
        echo"</tr>";
    echo"</table>";

the query should be more like :

SELECT * 
FROM cars 
WHERE make LIKE '%".$term."%' 
AND town LIKE '%".$town."%' 
AND colour LIKE '%".$colour."%' 
AND Reg LIKE '%".$Reg."%' 
AND price > ".$price." 
AND miles > ".$miles." 
LIMIT ".$offset;

although you may want to look into mysqli or PDO