Jump to content

Recommended Posts

Hello all,

I'm currently getting strange errors when trying to execute my code.

 

First off, here is what I have so far:

class DB extends MySQLi {
public function __construct() {
$conn = @$this->connect(HOST, USERNAME, PASSWORD);
if ($this->connect_errno) {
die("<br />Could not connect to MySQLi Database: " . $this->connect_error);
}
return $conn;
}
}

 

...and my code:

$conn1 = new DB();
$stmt = $conn1->stmt_init();
$stmt->prepare("UPDATE `user` SET `f1` = 2, `f2` = (?), `f3` = (?) WHERE `w1` = (?)");
$stmt->bind_param('ssi', $p1, $p2, $p3);
$stmt->execute();
$stmt->close();

 

The errors I get:

Warning: mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: invalid object or resource mysqli_stmt in /home/208/public_html/a1/p.php on line 61
Warning: mysqli_stmt::execute() [mysqli-stmt.execute]: invalid object or resource mysqli_stmt in /home/208/public_html/a1/p.php on line 62
Warning: mysqli_stmt::close() [mysqli-stmt.close]: invalid object or resource mysqli_stmt in /home/208/public_html/a1/p.php on line 63

 

I'm really confused as to what the issue is. I do know mysqli_stmt is its own class, but I'm not sure if declaring my DB class as mysqli_stmt would fix it, either.

Does anyone know what I'm doing wrong?

 

 

Thanks for any and all help,

Mark

Link to comment
https://forums.phpfreaks.com/topic/274624-issue-with-mysqli-prepared-statements/
Share on other sites

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.