调用非对象的成员函数 [英] call to member function on non object
本文介绍了调用非对象的成员函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
它表示调用一个非对象的成员函数set();我一直在修补这个问题3天,我无法弄清楚是什么导致了这个错误。
这里是代码
函数torrent_download($ item_details,$ output_type ='show_torrent')
{
$ template-> set('session',$ session) ;
$ torrent = $ show-> torrent_download($ session-> value('user_id'));
{
if($ session-> value('is_seller'))
{
$ show_tips = $ db-> count_rows('users',WHERE user_id = ''。$ session-> value('user_id')。'AND notif_a = 0);
if($ show_tips)
{
$ msg_member_tips ='< p class =errormessage>'。 MSG_MEMBER_TIPS_A。 '< br>'。 MSG_MEMBER_TIPS_B。 < / p为H.;
$ db-> query(UPDATE.DB_PREFIX。users SET notif_a = 1 WHERE user_id ='。$ session-> value('user_id')。');
}
$ template-> set('msg_member_tips',$ msg_member_tips);
$ b if(isset($ _ REQUEST ['form_download_proceed']))
{
$ download_result = download_redirect($ _ REQUEST ['winner_id'],$ session-> value('user_id'));
if($ download_result ['redirect'])
{
header('Location:'。$ download_result ['url']);
}
$ template-> set('msg_changes_saved','< p align =center>'。$ download_result ['display']。'< / p> ;');
$ b 解决方案我假设你在 torrent_download
函数中出现这个错误?
如果是这样,那是因为 $ template
未定义。您可以通过添加: global $ template
(以及任何其他你需要的外部变量)到你的函数的开始。
Can someone help a beginner?
It says that Call to a member function set() on a non-object; I have been tinkering with this for 3 days and am unable to figure out what is causing this error.
here is the code
function torrent_download($item_details, $output_type = 'show_torrent')
{
$template->set('session', $session);
$torrent = $show->torrent_download($session->value('user_id'));
{
if ($session->value('is_seller'))
{
$show_tips = $db->count_rows('users', "WHERE user_id='" . $session->value('user_id') . "' AND notif_a=0");
if ($show_tips)
{
$msg_member_tips = '<p class="errormessage">' . MSG_MEMBER_TIPS_A . '<br>' . MSG_MEMBER_TIPS_B . '</p>';
$db->query("UPDATE " . DB_PREFIX . "users SET notif_a=1 WHERE user_id='" . $session->value('user_id') . "'");
}
$template->set('msg_member_tips', $msg_member_tips);
}
if (isset($_REQUEST['form_download_proceed']))
{
$download_result = download_redirect($_REQUEST['winner_id'], $session->value('user_id'));
if ($download_result['redirect'])
{
header('Location: ' . $download_result['url']);
}
$template->set('msg_changes_saved', '<p align="center">' . $download_result['display'] . '</p>');
}
}
}
解决方案 I'm assuming you're getting this error inside the torrent_download
function?
If so, that's because $template
is undefined. Perhaps you defined it in the global script, but functions don't inherit that.
You can prevent this issue by adding: global $template
(and any other variable from the outside you need) to the start of your function.
这篇关于调用非对象的成员函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文