MySQLi Un-prepare-d

Hi guys, I am converting my old mysql_ * queries to mysqli, except that I have a nasty problem.

$st = $this->Sql->prepare("INSERT INTO tblPlayerOnline (SteamID,PlayerName,IPAddress,ConnectedDate) VALUES (?, ?, ?, ?)") or die($this->Sql->error);
/* 225 */ $st->bind_param("i", $SteamID);
$st->bind_param("ssi", $PlayerName, $IPAddress, $TimeNow);
$st->execute();

Fatal error: Call to a member function bind_param() on a non-object in /home/vanrust/public_html/rework/class/Players.class.php on line 225

But when I dump $this->Sql, I get object(mysqli)#2 (19) { bla bla, so I'm not sure if this error tells me.

Dump $this->Sql http://pastebin.com/gdKAgT4D

Any guidance is appreciated!

PS Looked everywhere -.-

+4
source share
3 answers

Okay, so it a little disappointed me, but I found that the answer was in front of me all the time at $this->Sql->stat. Oddly enough, 400 open tables looked like a pretty good even number, but this was clearly the maximum.

$st->close() , .

0

prepare mysqli_prepare, , .. - .

mysqli_report(MYSQLI_REPORT_ALL) ( mysqli_driver->report_mode). , prepare .

mysqli_report(MYSQLI_REPORT_ALL);

//Or if you just want an exception when Mysqli has an error? 
//Set the reporting level to 
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

, mysql_prepare. , :

if ($stmt = $this->Sql->prepare(....)) {
    //Yep, we can now start binding parameters
} else {
    //Noooooo.. got error?
}
0

, $st null, , .

, :

if (!$st) {
     echo "Prepare failed: (" . $this->Sql->errno . ") " . $this->Sql->error;
}
-1

Source: https://habr.com/ru/post/1584004/


All Articles