Smarty致命错误

时间:2012-08-12 08:36:22

标签: php mysql smarty

我正在使用以下代码

require 'Smarty/libs/Smarty.class.php';
$smarty = new Smarty;
$sel=mysql_query("select id, name from form");  
$smarty->assign('contact', $db->getRow($sql));
$smarty->display('testfunction.tpl');

我收到错误:

Fatal error: Call to a member function getRow() on a non-object in D:\xampp\htdocs\smarty\testfun.php on line 21

1 个答案:

答案 0 :(得分:1)

您尚未声明任何$ db对象。 请改用:

$smarty->assign('contact', mysql_fetch_row($sel));