Jump to content

Fatal error: Call to undefined method


Go to solution Solved by Jacques1,

Recommended Posts

I try to set up a session for an chat betwen two users as i try to establish it it throws out following error message : 
Fatal error: Call to undefined method SPOP::prepare() in D:\XAMPPmm\htdocs\***\CORE\ADM.php on line 219


Callout: 

if (isset($_POST['submitcon'])) {
  $UID = $userRow['userId'];
  $TARGET = $_POST['uid'];
  $SID = $UID . $TARGET;
  $res0 = $SPOP->establishsession($UID,$TARGET,$SID,0); 
}

ADM.php:

public function establishsession($UID,$TARGET,$SID,$STMT) { # func zum establieren von chats so das der nutzter einen chat bekommt (SESSION SETUP)
	switch ($STMT) {
		case 0: # establish
			try {
		$sql = $this->prepare("INSERT INTO csessionsub(FROM_,TO,SESSID) VALUES(:f,:t,:s)");
		$sql->execute(array(':f' => $UID, ':t' => $TARGET, ':s' => $SID));
		return 1;
		} catch (PDOException $ex) {
			echo $ex->getMessage();
			return 0;
	    }
			break;
		case 1: # delete 
			try {
		$sql = $this->prepare("DELETE FROM csessionsub WHERE SESSID=:s");
		$sql->bindparam(":s", $SID);
		$sql->execute();
		return 1;
		} catch (PDOException $ex) {
			echo $ex->getMessage();#
			return 0;
	    }
			break;
		default:
			return 0;
			break;
	}
	

}

Any sugestions ?

Link to comment
https://forums.phpfreaks.com/topic/301802-fatal-error-call-to-undefined-method/
Share on other sites

  • Solution

You're trying to call $this->prepare() within your SPOP object (whatever that may be), but it doesn't have a prepare() method. I'm sure you actually meant something like this:

$this->db->prepare(...)
     ^^^^
     or whatever the attribute with the PDO instance is called
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.