Jump to content

Issue With MySQLi Prepared Statements


Mko

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.