This is the error message I am getting: Fatal error: Uncaught ArgumentCountError: The number of elements in the type definition string must match the number of bind variables in /home/fighters/test.fighterspalace.com/mob1.php:309 Stack trace: #0 /home/fighters/test.fighterspalace.com/mob1.php(309): mysqli_stmt->bind_param() #1 {main} thrown in /home/fighters/test.fighterspalace.com/mob1.php on line 309
Here is the code:
if (isset($_GET['accept'])) {
$accept_id = $mysqli->real_escape_string($_GET['accept']);
$mob = fetchMob($accept_id, $mysqli);
$quest = fetchQuest($accept_id, $mysqli);
if ($mob && $quest) {
if ($mob['type'] != 'Q') {
echo "This is not a quest mob!";
exit;
}
// Ensure the quest can only be accepted once at a time
$stmt = $mysqli->prepare("SELECT COUNT(*) FROM quest_log WHERE quest_id = ? AND user_id = ? AND status != 'complete'");
$stmt->bind_param("ii", $quest['id'], $stat['id']);
$stmt->execute();
$stmt->bind_result($count);
$stmt->fetch();
$stmt->close();
if ($count > 0) {
echo "You've already accepted this quest.";
echo "</center></td></tr>";
echo "<tr><td><center><a href='https://test.fighterspalace.com/World.php'>LEAVE</a></center></td></tr>";
echo "</table></center>";
exit;
}
// Check if the quest can be done again
if ($quest['max'] != 0) {
$stmt = $mysqli->prepare("SELECT COUNT(*) FROM quest_log WHERE quest_id = ? AND user_id = ?");
$stmt->bind_param("ii", $quest['id'], $stat['id']);
$stmt->execute();
$stmt->bind_result($total_count);
$stmt->fetch();
$stmt->close();
if ($total_count >= $quest['max']) {
echo "You cannot do this quest again.";
echo "</center></td></tr>";
echo "<tr><td><center><a href='https://test.fighterspalace.com/World.php'>LEAVE</a></center></td></tr>";
echo "</table></center>";
exit;
}
}
$tasks = fetchTasks($quest['id'], $mysqli);
// Check if there are any tasks
if (empty($tasks)) {
echo "This quest has no tasks defined.";
exit;
}
$first_task = $tasks[0];
$stmt = $mysqli->prepare("
INSERT INTO quest_log (
user_id, quest_id, current_task_id,
kills_remaining1, kill_name1,
kills_remaining2, kill_name2,
kills_remaining3, kill_name3,
kills_remaining4, kill_name4,
kills_remaining5, kill_name5,
kills_remaining6, kill_name6,
kills_remaining7, kill_name7,
kills_remaining8, kill_name8
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
");
$stmt->bind_param(
"iiiisissississississi",
$stat['id'],
$quest['id'],
$first_task['id'],
$first_task['kills_needed1'],
$first_task['kill_name1'],
$first_task['kills_needed2'],
$first_task['kill_name2'],
$first_task['kills_needed3'],
$first_task['kill_name3'],
$first_task['kills_needed4'],
$first_task['kill_name4'],
$first_task['kills_needed5'],
$first_task['kill_name5'],
$first_task['kills_needed6'],
$first_task['kill_name6'],
$first_task['kills_needed7'],
$first_task['kill_name7'],
$first_task['kills_needed8'],
$first_task['kill_name8']
);
if ($stmt->execute()) {
echo "<center><table border=1>
<tr><td><center><b>{$mob['name']}</b></center></td></tr>
<tr><td><center>{$quest['description']}</center></td></tr>
<tr><td><center>First Task: {$first_task['description']}<br>";
for ($i = 1; $i <= 8; $i++) {
if ($first_task["kills_needed{$i}"] > 0 && !empty($first_task["kill_name{$i}"])) {
echo "I need you to kill <b>{$first_task["kills_needed{$i}"]} {$first_task["kill_name{$i}"]}'s!<br><br></b>";
}
}
for ($i = 1; $i <= 8; $i++) {
$item_name = $first_task["items_needed{$i}"];
if (!empty($item_name)) {
echo "<br>I need 1 {$item_name}<br>";
}
}
echo "</center></td></tr>";
echo "<tr><td><center><a href='https://test.fighterspalace.com/World.php'>LEAVE</a></center></td></tr>";
echo "</table></center>";
} else {
echo "Failed to accept the quest. Error: " . $stmt->error;
}
} else {
echo "Invalid accept ID.";
}
exit;
}
I have tried multiple variations and continue to get the same error, not sure whats going on
Tristan Adams is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.