Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
|
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 15th, 2007, 09:37 AM
Registered User
 
Join Date: Sep 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Call to a member function query() on a non-object

Hi,

I'm building an object to get results from a database. This is the code:

<?php
class bf_conn
{
// define attributes
...

function __construct()
    {
    $bf_connect = new mysqli($this->sql_host, $this->sql_user, $this->sql_pass, $this->sql_dbase);
    }

function db_result()
    {
    $bf_result = $this->bf_connect->query($this->bf_query);
    return $bf_result;
    }
}
// connect
$check_db = new bf_conn;
// query
$login_query = "SELECT * FROM login_log";
$check_db->bf_query = $login_query;
// query exec
$login_result = $check_db->db_result();
// count results
$check1 = $login_result->num_rows;
// display
echo $check1;
?>

I get the following error: Call to a member function query() on a non-object in.... with a reference to the following line:

$bf_result = $this->bf_connect->query($this->bf_query);

Anybody got any suggestions?

Thanks!







Similar Threads
Thread Thread Starter Forum Replies Last Post
Call to function Awkuzu BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 September 19th, 2007 06:13 PM
Call a Function stealthdevil Access VBA 2 November 2nd, 2006 10:38 AM
How to call javascript function from VB function vinod_yadav1919 VB How-To 0 February 13th, 2006 06:03 AM
error Call to undefined function: query() gmanon Wrox Book Feedback 1 November 20th, 2003 06:34 PM
I.H. Beg VC++ Add Member Function n6532l Visual C++ 1 September 25th, 2003 01:25 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.