can somebody tell me what the error is

Call to a member function insertseek1() on a non-object

Recommended Answers

All 5 Replies

Without the line showing how the function is defined it is hard to tell but it looks like you are using a method as a function. A method is an oop thing that can be defined exactly the same way as a function but within a class with a constructor. Although the only oop I do is with php-gtk, I think to use a method you need to call it with its parent like below but with the right variable name:

$parent->insertseek1();

And as I said, I don't know exactly how accurate all of that is but I do believe that it is because you are using an oop method as a function.

$res=$db->insertseek1($user,$pss);
function insertseek1($user,$pss)

	{
	
		$db = NULL;

		$db = new MyDBHandler;

		$db -> init();

		$sql_string = "insert into login(username,password,priv)value('".$user."','".$pss."','2')";

		$result = $db->Insert($sql_string);
		
		$db->CloseConnection();

		return $result;

	}

Although I'm not the greatest with oop, I did some research and turns out that the function is not an object. That could be one of two reasons. 1 reason is the way the function is defined and the other is what value it returns (not sure about the last one). So try replacing the first line of that last code box with one of the following but other than that I don't have much of a clue.

public function insertseek1($user,$pss)
// or if the above replacement doesn't work try the below in the same line
private function insertseek1($user,$pss)

its not working

You are declaring insertseek1 as a normal function but then calling it from an object ($db) that doesn't exist in this context. Just do this:

$res=insertseek1($user,$pss);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.