php - 聪明的 fatal error

标签 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

最佳答案

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

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

关于php - 聪明的 fatal error ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11920865/

相关文章:

php - 对 SimpleXML 对象数组进行排序

php - 如何 : Displayed image file name different than actual filename on server

php - 有没有办法在 Heroku 中使用 PHP WebSocket?,默认情况下似乎只支持其他技术

php - 使用 foreach 从 MySQL 中检索数据

php - 如何解析php中的smarty函数?

javascript - 购物车 : Using ajax calls in template - 403 Forbidden Error

php - INSERT Row If Does Not Exist mysql with POST 插入行

php - 运行 Update Query MySQL 时所有数据都变为 NULL

mysql - 在 phpmyadmin 中仅将几个值设置为要枚举的域

php - 在 Smarty 中从数组中获取某些值