I have a problem, I cannot see why I get this error Call to a member function bind_param() on a non-object in.
I am trying to run through a list of items user by user.
$users = "select distinct(user_id) as user from itemList";
$result = mysqli_query($DBconnection,$users);
while($row = mysqli_fetch_array($result))
{
$listofUsers[] = $row[0];
}
shuffle($userlist);
//print_r($userlist);
$finished = false;
while(!$finished)
{
$finished = true;
//iterate through userlist array of user id's
echo "after while";
foreach($listofUser as $user)
{
$result2 = $DBconnection->prepare("select item_id from itemlist where user_id = ?");
$result2->bind_param("i", $user);
$result2->execute();
$result2->store_result();
//check that is there is still a item in this user itemlist
if($result2->num_rows > 0)
{
//echo"this is the user $user";
// get any items on this users itemlist
$stmt = $DBconnection->prepare("SELECT item_id FROM itemlist where user_id = ? and isThere = 'yes'");
$stmt->bind_param("i",$user);
$stmt->execute();
stmt_bind_assoc($stmt, $row);
// loop through all result rows
echo "b4 if";
if($stmt->fetch())
{
//echo $user;
foreach($row as $i)
{
echo "this is $i in foreach";
getPosition($row,$user);
}
}
array_reverse($userlist);
$finished = false;
//echo"this is userlist";print_r($userlist);echo"<br>";
}
}
}

New Topic/Question
Reply




MultiQuote




|