I need to pass the results of a query to a seperate class
but I keep getting an error saying that a mysqli object is
required.
Ex:
With a class like:
Code: Select all
class Test
{
function Do_Stuff($results)
{
while ($row = mysqli_fetch_array($results)
echo $rowї0];
}
}everything I need in a script like:
Code: Select all
$obj = new Test();
$res = mysqli_query($dbcon, $query);
obj->Do_Stuff($res);"mysqli_fetch_array() expects parameter 1 to be mysqli, object
given in ....filename...."
but when I use the $res in the script its fine.
Can you not pass query result objects or is this loosing scope?
Thanks in advance
nqaul