[PHP/MySQLi] Fatal error: Call to a member function execute() on a non-object

Discussion in 'PHP' started by RastaLulz, May 24, 2011.

  1. #1
    I do not understand why I am getting an error.. I have done this hundreds of times.

    Here's the error that I'm getting:
    Fatal error: Call to a member function execute() on a non-object in xxx/core.php on line 11
    Code (markup):
    Here's the code:
        $sendMessage = $db->prepare("INSERT INTO shouts SET message = ?");
        $message = 'wtf';
        $sendMessage = $sendMessage->bind_param('s', $message);
        $sendMessage->execute();
    PHP:

     
    RastaLulz, May 24, 2011 IP
  2. Jo$h

    Jo$h Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Well, I'm not sure just quite what your problem is. Please explain more.
     
    Jo$h, May 24, 2011 IP
  3. RastaLulz

    RastaLulz Member

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #3
    Issue sorted - I'm an idiot.

     $sendMessage = $sendMessage->bind_param('s', $message); 
    Code (markup):
    Should just be:

     $sendMessage->bind_param('s', $message); 
    Code (markup):
     
    RastaLulz, May 24, 2011 IP