900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > Fatal error: Call to a member function fpage() on a non-object解决方案

Fatal error: Call to a member function fpage() on a non-object解决方案

时间:2024-03-26 16:05:30

相关推荐

Fatal error: Call to a member function fpage() on a non-object解决方案

后端开发|php教程

nbsp,product,list,gt,GLOBALS

后端开发-php教程

Fatal error: Call to a member function fpage() on a non-object

smarty里面我通过调用分页函数,page.class.php已经在页面调用过,并且已经实例化,具体语句是这样的:

/*产品列表*/

function get_product_list($cat_id)

{

if($cat_id)

{

$num=6;

$where = ” where classid=’$cat_id’ and shenhe=1 “;

$sql1 = $GLOBALS[‘db’]->query(“select * from “.$GLOBALS[‘db’]->table(‘product’).$where.””);

$total = $GLOBALS[‘db’]->num_rows($sql1);

}

else

{

$num=6;

$where = ” where shenhe=1 “;

$sql2=$GLOBALS[‘db’]->query(“select * from “.$GLOBALS[‘db’]->table(‘product’).$where.””);

$total=$GLOBALS[‘db’]->num_rows($sql2);

}

$page=new page($total,$num);

//echo $total;

//exit();

$sql=”select * from “.$GLOBALS[‘db’]->table(‘product’).$where.”order by addtime desc {$page->limit}”;

while($row=$GLOBALS[‘db’]->fetch_array($sql))

{

$url=$GLOBALS[‘db’]->rewrite_url(‘cpxx_xx’,$row[‘productid’]);

$product_list[]=array(

“id” => $row[‘productid’],

“title” => $row[‘title’],

“image” => $row[‘image’]

);

}

return $product_list;

}

/*初始化数据*/

$smarty->assign(‘ur_here’,$db->ur_here(‘product_class’,$cat_id));

$smarty->assign(‘product_category’,$db->get_product_category(”)); //产品展示左侧分类列表

$smarty->assign(‘product_list’,get_product_list($cat_id)); //产品列表

$smarty->assign(‘page_nav’,$page->fpage(array(3,4,5,6,7,0,1,2,8))); //产品分页这句出错,看看哪位大神给解惑,不胜感激~!

——解决方案——————–

$page 是在函数中初始化的。也就是他是一个局部变量,当然你不能在函数外使用。

——解决方案——————–

作为函数的返回值返回,例如:

return $product_list;

改为 return array(

‘list’=>$product_list,

‘fpage’=>$page->fpage(array(3,4,5,6,7,0,1,2,8)),

)

——解决方案——————–

函数返回值改成#5那样写。

诱导源码教程,网页设计vscode文字变色,ubuntu 主机扫描,tomcat查看当前内存,爬虫公众平台,php 判断是xml格式,seo服务光算科技.简介,多城市网站程序,access学生成绩管理系统模板lzw

$smarty->assign(‘product_list’,get_product_list($cat_id)); //产品列表

$smarty->assign(‘page_nav’,$page->fpage(array(3,4,5,6,7,0,1,2,8)));

改为:

$ar = get_product_list($cat_id);

$smarty->assign(‘product_list’,$ar[‘list’]); //产品列表

$smarty->assign(‘page_nav’,$ar[‘fpage’]);

——解决方案——————–

function get_product_list($cat_id)

{

global $page; //加上这句

if($cat_id)

……….

富贵2源码是那家公司的,ubuntu获取ip文件,tomcat7修改端口好,javaweb爬虫项目,php网页源码怎么下,seo教程排名lzw

其他无需改动

网页聊天 源码,vscode安装命令,ubuntu htk,tomcat怎么作用,sqlite 提高速度,百度html插件,如何进行前端框架学习,潮湿的地方长的爬虫,php 添加用户,北京seo营销方式,手机网站页面布局,网页开关灯效果,威锋论坛模板lzw

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。