Closed Thread
Results 1 to 3 of 3

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

  1. #1
    Join Date
    Mar 2008
    Posts
    7,145
    Rep Power
    86

    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?

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Jordan Guest

    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.

  4. #3
    Join Date
    Mar 2008
    Posts
    7,145
    Rep Power
    86

    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.

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. call to undefined function mssql_connect()
    By newphpcoder in forum PHP Development
    Replies: 8
    Last Post: 10-02-2010, 12:08 AM
  2. Call a function only once without bool flag?
    By TCristoforo in forum C and C++
    Replies: 4
    Last Post: 09-15-2010, 11:53 AM
  3. Call C function from Php
    By anis0408 in forum PHP Development
    Replies: 2
    Last Post: 09-10-2010, 02:19 AM
  4. How to call function? C
    By naspek in forum C and C++
    Replies: 13
    Last Post: 09-01-2009, 10:18 PM
  5. Call a vb6 com+ object...
    By chepla in forum C# Programming
    Replies: 2
    Last Post: 08-07-2008, 11:16 AM

Tags for this Thread

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