I have the following piece of code. It works when executed in the sql interface of phpmyadmin but when I execute it on the server $stmt = $con->prepare($sql)
always returns false and I exit with an error.
Note that $stmt = $con->prepare($sql)
does not return an error messages. I'm afraid I might be doing something wrong here too?
I assume I'm missing something important here!
Also the Update statement worked correctly before I modified it to return a comma separated list of updated IDs.
$sql = "SET @uids := null;
UPDATE userpicks, brackets
SET userpicks.player1 = ?, userpicks.pick = ?
WHERE userpicks.id_user = ? AND userpicks.id_tournament = ? AND brackets.stage > ? AND userpicks.player1 = ?
AND ( SELECT @uids := CONCAT_WS(',', brackets.id, @uids) );
SELECT @uids;";
if ($stmt = $con->prepare($sql)) {
$stmt->bind_param('iiiiii', $noPlayerID, $noPlayerID, $_SESSION ["id"], $id_tournament, $bracket_stage, $id_player);
} else {
echo mysqli_error($con);
return getJSONArrayError("Error occurred");
}