I am having problem with this line of code
$db->select($tbl, plan_name,NULL,'plan_name ="{$pname}"');
see my dump of the function
SELECT plan_name FROM plans WHERE plan_name ="{$pname}"
The variable $pname is passed as literal.
Single-quote literals don't get variables replaced inside them.
For reference: http://www.php.net/manual/en/language.types.string.php