Home Ask Login Register

Developers Planet

Your answer is one click away!

Tanvi Malhotra February 2016

Prepare not defined

I have tried setting sessions which are stored in database.I have achieved this through implementing SessionHandlerInterface class.However i havenot used prepared statements before but now i want to implement prepared statements in order to make it sql injection proof.However , when i try the prepare method it shows me an error

Method Prepare not defined in Class

i even tried extending mysqli_stmt class which contains the methods for prepared statements.

This is the full code of session class that stores sessions inside the database.


Part of the code to make the question much more clear

class SysSession implements SessionHandlerInterface
   private $link;

public function open($savePath, $sessionName)
    $link = new mysqli("localhost","root","","cakenbake");
        $this->link = $link;
        return true;
        return false;
public function close()
    return true;
public function read($id)

    $result = mysqli_query($this->link,"SELECT Session_Data FROM Session WHERE Session_Id = '".$id."' AND Session_Expires > '".date('Y-m-d H:i:s')."'");

    /*$result=$this->link->prepare("Some query inside")
     * This shows up an error stating prepare method not found

    if($row = mysqli_fetch_assoc($result)){
        return $row['Session_Data'];
        return "";


Tanvi Malhotra February 2016

The problem was with my IDE.It was the one who was showing errors.Restarted my IDE and it worked fine.

Post Status

Asked in February 2016
Viewed 2,561 times
Voted 4
Answered 1 times


Leave an answer

Quote of the day: live life