Jump to content

Call to a member function bind_param() on a non-object?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
chili5

chili5

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 7,247 posts
When I use my registration program on the CC server I get a message that looks like this:

Quote

Fatal error: Call to a member function bind_param() on a non-object in newAccount.php on line 63

Now the weird thing is, when I run the same script locally, it works. Any thoughts?

This is the code that is having the problem:



if (count($errors) == 0) {

	// no errors have occured so apply sha1 to passwords

	$pwd = sha1($pwd);

	$pwdConfirm = sha1($pwdConfirm);

	

	// submit to database

	$sql = "INSERT INTO users (user_name, user_pwd, user_regdate, user_country, user_email, user_activated, user_points, user_levelid, activation_key) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?);";

	$stmt = $dbConn->prepare($sql);


	// bind the variables to the prepared statements replacing the ? marks

	$stmt->bind_param("ssiissiis",$userName,$pwd,$regdate,$country,$email,$activated,$points,$levelId, $activateKey);

	$activated = "0"; // not yet activated

	$points = 0;

	$levelId = 0; // level id 0 means the user is a normal user without admin permissions

	$activateKey = makeKey();

	

	$stmt->execute();

	

	$message = "$userName has been registered. You may now login.<br />";

}


Any thoughts?

#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
In your INSERT statement you have a field named activation. When I look at your tables and see the table "users" you do not have the field. This would cause $dbConn->prepare to fail and not return an object which would cause bind_param to throw a fatal error.

#3
chili5

chili5

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 7,247 posts
thank you!

I completely forgot that I added that field locally. :(


+rep for you.