Fetch Array Error :( [Resolved]
Posted: Mon Oct 07, 2013 9:07 am
I can't figure out this error either. I've searched google for an hour, but nothing explains why I get the error, so I can't fix it
Line 176
use_item.php
Code: Select all
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\login3\use_item.php on line 176Code: Select all
while ($row = mysqli_fetch_array($user_query, MYSQLI_ASSOC)) { Code: Select all
<?php
if (isset($_GET['randid'])) {
$randid=$_GET['randid'];
$sql = "SELECT * FROM inventory WHERE randid='$randid'";
$user_query = mysqli_query($db_conx, $sql);
$numrows = mysqli_num_rows($user_query);
while ($row = mysqli_fetch_array($user_query, MYSQLI_ASSOC)) {
if ($row['name']) {
} else
$name = $row['name'];
$stats1 = $row['stats'];
$statadd = $row['statadd'];
$type = $row['type'];
$randid=$row['randid'];
$id = $_SESSION['userid'];
if ($type == "healing") {
$newhp = $statadd + $stats_hpoints;
if ($newhp > $stats_maxhp) {
$newhp = $stats_maxhp;
}
$sql = "UPDATE stats set hpoints='$newhp' WHERE id='$id'";
$user_query = mysqli_query($db_conx, $sql);
$sql = "DELETE from inventory where id='$id' AND randid='$randid' limit 1";
$user_query = mysqli_query($db_conx, $sql);
$stats_hpoints = $newhp;
$name = $row['name'];
echo "<br><br><span id='errormess'><big><center><font color='lime'> Used " . $name . " and recovered " . $statadd . " health" ."!</center><br></span></big></font>";
}
if ($type == "revive") {
$newturns = $statadd + $stats_turns;
if ($newturns > $stats_maxturns) {
$newturns = $stats_maxturns;
}
$sql = "UPDATE stats set turns='$newturns' WHERE id='$id'";
$user_query = mysqli_query($db_conx, $sql);
$sql = "DELETE from inventory where id='$id' AND randid='$randid' limit 1";
$user_query = mysqli_query($db_conx, $sql);
$name = $row['name'];
$stats_turns = $newturns;
echo "<br><br><span id='errormess'><big><center><font color='lime'> Used " . $name . " and recovered " . $statadd . " stamina" ."!</center><br></span></big></font>";
}
?>
</div>
<?php } } ?>