在Php中调用函数时出现致命错误[关闭]

I am trying to call a function for a shopping cart program which is as follows:

<?

    public function get_price($pid){
        $result=mysql_query("select price from products where serial=$pid");
        $row=mysql_fetch_array($result);
        return $row['price'];
    }


?>

Above code is stored in includes/db.php file and I am calling it as follows:

 <? include("includes/db.php"); ?>
  <table>
<tr><td>$ <?=get_price($pid)?></td></tr>
</table>

After running the script I am getting Fatal error: Call to undefined function get_price().I tried $this-> but that is not working.Can i get some guidance.

If the function get_price($pid) is not inside a class...remove the public part, but if it belong to a class you have to create the object to before to call it..