I have the following code which is generating error while fetching the elements of the array
$task = new task();
$task->connect();
$services = $task->viewTask_front_android($_GET['pno']);
print_r($services);
while($info = mysqli_fetch_assoc($services))
{
Print "<b>Name:</b> ".$info['starttime'] . " ";
} ?>
from the print_r(services) iam getting
Array ( [task_id] => 14 [user_id] => 123 [employee_id] => 456 [service_id] => 2 [starttime] => 2:00 AM [endtime] => 4:00 AM [servicename] => se a [servicedescription] => ddsdsd [employeename] => dsd [employeepicture] => pictures/noimage.gif [pic_path] => pictures/noimage.gif )
is there any problem with
while($info = mysqli_fetch_assoc($services))
it is generating error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\proj\android\services.php on line 70
$servicesis, it is not a valid MySQL result resource. Edit: It is already the result array (as you can see at the output), so no need to usemysqli_fetch_assoc. Just iterate normally over the array.fororforeachloop to iterate over the array.viewTask_front_androidalready gave you the result. There are no DB functions involved anymore.