Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

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

bind_param

  • Please log in to reply
2 replies to this topic

#1 chili5

chili5

    CC Mentor

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3038 posts
  • Programming Language:Java, C#, PHP, JavaScript, Ruby, Transact-SQL
  • Learning:C, Java, C++, C#, PHP, JavaScript, Ruby, Transact-SQL, Assembly, Scheme, Haskell, Others

Posted 23 June 2009 - 03:45 AM

When I use my registration program on the CC server I get a message that looks like this:

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?
  • 0

#2 Guest_Jordan_*

Guest_Jordan_*
  • Guest

Posted 23 June 2009 - 05:16 AM

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.
  • 0

#3 chili5

chili5

    CC Mentor

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3038 posts
  • Programming Language:Java, C#, PHP, JavaScript, Ruby, Transact-SQL
  • Learning:C, Java, C++, C#, PHP, JavaScript, Ruby, Transact-SQL, Assembly, Scheme, Haskell, Others

Posted 23 June 2009 - 05:21 AM

thank you!

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


+rep for you.
  • 0





Also tagged with one or more of these keywords: bind_param

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download