non-object php,PHP Call to a member function prepare() on a non-object error

Hi i need some help with this error I keep getting. It works fine everywhere else in the script except when I try to call it within this one function.

The function I am calling is: getTotalServers

Error: Fatal error: Call to a member function prepare() on a non-object in C:\xampp2\htdocs\runeloft\ss_sources\util.php on line 208

Calling in this function: function display_table($online, $where, $num_servers = null){ global $aaaa, $bbbb; $num_per_page = 30; $page = 1; // how many records per page $size = 10; // we get the current page from $_GET if (isset($_GET['page'])){ $page = (int) $_GET['page']; } $aaaa = getTotalServers(1, $num_servers);; $bbbb = $page; // create the pagination class $pagination = new Pagination(); $pagination->setLink("?action=status&page=%s"); $pagination->setPage($page); $pagination->setSize($size); $pagination->setTotalRecords($num_servers); global $g_headers; $g_headers = array( 'name' => 'Server Name', 'ip' => 'IP', 'port' => 'Port', 'uptime' => 'Uptime', 'online' => 'Status', ); $start = isset($_GET['start']) ? $_GET['start'] : 0; mysql_con(); global $g_mysqli; $start = $g_mysqli->real_escape_string($start); if(isset($_GET['sort']) && isset($g_headers[$_GET['sort']])){ $order_by = 'ORDER BY `'.$g_mysqli->real_escape_string($_GET['sort']).'` '.(isset($_GET['desc']) ? 'DESC' : 'ASC'); }else{ //default sort $order_by = 'ORDER BY `uptime` DESC, `time` ASC'; } //$order_by .= " LIMIT $start, $num_per_page"; $order_by .= " " . $pagination->getLimitSql(); if($start == 0 && $online == 1 && !isset($_GET['sort'])) echoTable('Spons', "`sponsored` != '0'", "ORDER BY `sponsored` DESC, RAND() LIMIT 10"); echoTable('Other', $where, $order_by, $online, $start, $num_per_page, $num_servers); close_mysql(); }

Called Function: function getTotalServers($online, $where, $num_servers = null){ $where = "`online` = '$online' AND `sponsored` = '0'"; if($num_servers == null){ global $g_mysqli; $stmt = $g_mysqli->prepare("SELECT COUNT(*) FROM `servers` WHERE ".$where) or debug($g_mysqli->error); $stmt->execute(); // bind result variables $stmt->bind_result($num_servers); $stmt->fetch(); $stmt->close(); } return $num_servers;

}

Thanks for any help.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值