troubleshooting Question

Call to a member function on a non-object in

Avatar of fosiul01
fosiul01Flag for United Kingdom of Great Britain and Northern Ireland asked on
5 Comments1 Solution1371 ViewsLast Modified:
Can i not call function  class function1 which is inside class1.class from  another function call funciton2 which is inside class2.class ??

if you can look at bellow code , its saying :Fatal error: Call to a member function query() on a non-object in.

Here I wrote a function( Register) to insert username and password in the table. This Register function is in UserAuthentication class.
problem is in :  query($sql); , which is actually a function from mysql.class

now i cant call this query($sql)  from Register function .

what i will have to do to call this function ??

class UserAuthentication 
function register($username, $password, $UserEmail)
		// sql query to Select all username with the selected username provided by user
		$sql = "SELECT * FROM users where username = '$username'";
		$result = &$db->query($sql);  <<------------- problem---------------------
		Return true;
require_once ('../DBClass/ConnectionString.php');
$username = $_POST[Username];
$userpassword = $_POST[Userpassword1];
$userpassword2 = $_POST[Userpassword2];
$userEmail = $_POST[UserEmail];
// Creating object of UserAuthentication class
$ObjUserAuthentication = new UserAuthentication();
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros