I've searched high and low for an answer to this question, to no avail. I reach out to you my fellow coders. :-)
I have the following, seemingly simple PHP code:
$query = "SELECT marketid, type, quantity, price, datetime, bundleid, state, stoplossprice FROM orders WHERE type = ? AND state = ?";
$stmt = $login->mySQLi->prepare($query);
if(!$stmt) {
throw new Exception(mysqli_error($login->mySQLi));
}
$stmt->bind_param("ss", $strOrderType, $strOrderState);
if($stmt)
{
if(!$stmt->execute())
{
// Return an error
}
}
$stmt->store_result();
$stmt->bind_result($marketid, $ordertype, $quantity, $buyprice, $buydatetime, $bundleid, $orderstate, $stoplossprice);
while ($stmt->fetch()) {
// Do something with the returned data
}
$stmt->close();
I also have almost the exact same code several other places, and in the other places it works. But, for some reason it's terminating when executing the execute()
statement.
Also, after executing the prepare()
statement, $stmt->affected_rows
equals -1.
I read in the MySQLi docs, a value of -1 means "-1 indicates that the query returned an error". But, for I can't figure out how to output the error message from $stmt
. $stmt->errno
and $stmt->error
have no values.
I've also checked the log file for MySQL and it shows the following:
141117 21:21:39 222 Prepare SELECT marketid, type, quantity, price, datetime, bundleid, state, stoplossprice FROM orders WHERE type = ? AND state = ? 222 Statistics 223 Statistics
141117 21:21:54 222 Statistics
223 Statistics
141117 21:21:55 222 Statistics
223 Statistics
141117 21:21:56 222 Statistics
223 Statistics
141117 21:21:57 222 Execute SELECT marketid, type, quantity, price, datetime, bundleid, state, stoplossprice FROM orders WHERE type = 'Buy' AND state = 'Pending' 223 Quit
222 Close stmt
222 Quit
Help me Obi-wan Kenobi, you're my only hope (and yah, it's late, I'm feeling a bit slappy)!