+ Reply to Thread
Results 1 to 3 of 3

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

  1. #1
    Code Slinger chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5's Avatar
    Join Date
    Mar 2008
    Posts
    7,022
    Blog Entries
    1

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

    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:

    Code:
    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?
    "Whenever you remember, I'll be there/
    Remember how we reached that dream together" - Carrie Underwood

  2. #2
    Administrator Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan's Avatar
    Join Date
    Nov 2005
    Location
    Hendersonville, NC
    Posts
    24,556
    Blog Entries
    97

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

    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. #3
    Code Slinger chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5's Avatar
    Join Date
    Mar 2008
    Posts
    7,022
    Blog Entries
    1

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

    thank you!

    I completely forgot that I added that field locally.


    +rep for you.
    "Whenever you remember, I'll be there/
    Remember how we reached that dream together" - Carrie Underwood

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. XML Result from PHP?
    By Ricardo-san in forum PHP Forum
    Replies: 14
    Last Post: 04-09-2009, 11:03 PM
  2. PHP Objects
    By chili5 in forum PHP Tutorials
    Replies: 5
    Last Post: 03-24-2009, 05:12 PM
  3. Replies: 0
    Last Post: 11-27-2008, 01:30 AM
  4. PHP 5 and OOP
    By Jordan in forum PHP Tutorials
    Replies: 11
    Last Post: 09-22-2008, 01:58 AM
  5. using Template function
    By Chinmoy in forum C Tutorials
    Replies: 4
    Last Post: 04-03-2008, 04:16 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts