Edit:
Okay, so, I did a little more testing and found out it was stored procedures that mess everything up. But I don't know why stored procedures mess it up. See my first comment under this post for details.
/Edit
Okay, so, I've got this school project I've been working on using my laptop as a server. However, I cannot submit it without putting it on the school's servers. My lecturer finally gave me access to it and I finally was able to start migrating my project there.
After fixing a tonne of smaller issues like default charset mismatch and case sensitivity issues, this particular problem came along and has me stumped. I spent a few hours running through my code, looking through PHP documentation and mangling my code to print out walls of debug text and finally re-produced the bug with as little code as possible.
Here's the PHP code:
<?php
define("HOST", "someHost");
define("USER", "someUser");
define("PASS", "somePass");
define("DB" , "someDB");
$conn = mysqli_connect(HOST, USER, PASS, DB);
$stmt1 = $conn->stmt_init();
if (!$stmt1->prepare("CALL P_Topics_Get(33);")) {//If I uncomment this, I get an error when trying to prepare $stmt2
//if (!$stmt1->prepare("SELECT * FROM Topics WHERE id = 33;")) { //If I uncomment this, I DON'T get an error anywhere
//if (!$stmt1->prepare("SELECT 0, 'name', 1, 2, 3;")) {//If I uncomment this, I DON'T get an error anywhere
echo "Failed to prepare 1: " . $conn->errno . ", " . $conn->error;
exit;
}
if (!$stmt1->execute()) {
echo "Failed to execute 1: " . $conn->errno . ", " . $conn->error;
exit;
}
if (!$stmt1->store_result()) {
echo "Failed to store 1: " . $conn->errno . ", " . $conn->error;
exit;
}
$stmt1->bind_result($id, $name, $step, $decAmt, $maxAmt);
if (!$stmt1->fetch()) {
echo "Failed to fetch 1: " . $conn->errno . ", " . $conn->error;
exit;
}
echo "$id, $name, $step, $decAmt, $maxAmt<br>";
$stmt1->free_result();
$stmt1->close();
$stmt2 = $conn->stmt_init();
if (!$stmt2->prepare("SELECT 2;")) {
echo "Failed to prepare 2: " . $conn->errno . ", " . $conn->error;
exit;
}
if (!$stmt2->execute()) {
echo "Failed to execute 2: " . $conn->errno . ", " . $conn->error;
exit;
}
if (!$stmt2->store_result()) {
echo "Failed to store 2: " . $conn->errno . ", " . $conn->error;
exit;
}
$stmt2->bind_result($val2);
if (!$stmt2->fetch()) {
echo "Failed to fetch 2: " . $conn->errno . ", " . $conn->error;
exit;
}
echo "Val 2: " . $val2 . "<br>";
$stmt2->free_result();
$stmt2->close();
echo "success";
?>
P_Topics_Get() is a simple select statement from a table:
SELECT
*
FROM
Topics t
WHERE
t.id = topicId;
So.. Yeah. This works on my localhost with no errors but messes everything up on the school's machine. This is the first time I have ever encountered the 2014 error.. And it's only 2013! (/joke)
Anyone know what's up?