Forum Moderators: open
$mysqli = new mysqli('localhost', 'user', 'pw', 'db');
$stmt = $mysqli->stmt_init();
$stmt->prepare('select fld1, fld2 from filename');
$stmt->execute();
$stmt->bind_result($fld1, $fld2);
while ($stmt->fetch()) {
...
$stmt2 = $mysqli->stmt_init();
$stmt2->prepare('update filename...);
}
For brevity, I've omitted the error trapping, but the first error occurs at that second prepare call: "Commands out of sync; you can't run this command now."
Why does this error occur? Can mysqli not handle multiple statement objects for the same connection? Or am I missing something obvious?