Mko Posted February 18, 2013 Share Posted February 18, 2013 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 More sharing options...
jazzman1 Posted February 18, 2013 Share Posted February 18, 2013 How do you initialize your database name? Link to comment https://forums.phpfreaks.com/topic/274624-issue-with-mysqli-prepared-statements/#findComment-1413093 Share on other sites More sharing options...
smarburcism Posted February 18, 2013 Share Posted February 18, 2013 Hi i'm new here! How can i contact administration of this forum? Link to comment https://forums.phpfreaks.com/topic/274624-issue-with-mysqli-prepared-statements/#findComment-1413101 Share on other sites More sharing options...
kicken Posted February 18, 2013 Share Posted February 18, 2013 Check the return value of $stmt->prepare, it's probably failing. Add some code to report mysql's errors to see why it fails. Link to comment https://forums.phpfreaks.com/topic/274624-issue-with-mysqli-prepared-statements/#findComment-1413117 Share on other sites More sharing options...
Mko Posted February 18, 2013 Author Share Posted February 18, 2013 Thanks! It turned out I forgot to add this line in after declaring $conn1: $conn1->select_db("database"); Link to comment https://forums.phpfreaks.com/topic/274624-issue-with-mysqli-prepared-statements/#findComment-1413203 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.