Welcome Guest, Not a member yet? Register   Sign In
CI4: Invalid argument supplied for foreach()
#1
Question 
(This post was last modified: 03-31-2022, 03:47 AM by Ahmed Haroon.)

i am trying to learn CI4 as advised by @InsiteFX on given link Nice tutorials - IncludeBeer , as it is first tutorial of CI4, i am just copy & pasting page by page the included code to see the results. from page 1 to 5 it was working fine but after 6th page it is showing below error. please help what i missed or doing wrong. 
[Image: CI4-Invalid-Argument-Supplied-For-Foreach.jpg]
regards

Error Log:
Quote:INFO - 2022-03-31 05:14:04 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
CRITICAL - 2022-03-31 05:14:04 --> Invalid argument supplied for foreach()
#0 D:\xampp\htdocs\ci4.test\app\Views\recipe_list.php(86): CodeIgniter\Debug\Exceptions->errorHandler(2, 'Invalid argumen...', 'D:\\xampp\\htdocs...', 86, Array)
#1 D:\xampp\htdocs\ci4.test\vendor\codeigniter4\framework\system\View\View.php(210): include('D:\\xampp\\htdocs...')
#2 D:\xampp\htdocs\ci4.test\vendor\codeigniter4\framework\system\View\View.php(213): CodeIgniter\View\View->CodeIgniter\View\{closure}()
#3 D:\xampp\htdocs\ci4.test\vendor\codeigniter4\framework\system\Common.php(1089): CodeIgniter\View\View->render('recipe_list', Array, true)
#4 D:\xampp\htdocs\ci4.test\app\Controllers\RecipesController.php(79): view('recipe_list', Array)
#5 D:\xampp\htdocs\ci4.test\vendor\codeigniter4\framework\system\CodeIgniter.php(832): App\Controllers\RecipesController->index()
#6 D:\xampp\htdocs\ci4.test\vendor\codeigniter4\framework\system\CodeIgniter.php(419): CodeIgniter\CodeIgniter->runController(Object(App\Controllers\RecipesController))
#7 D:\xampp\htdocs\ci4.test\vendor\codeigniter4\framework\system\CodeIgniter.php(326): CodeIgniter\CodeIgniter->handleRequest(NULL, Object(Config\Cache), false)
#8 D:\xampp\htdocs\ci4.test\public\index.php(37): CodeIgniter\CodeIgniter->run()
#9 {main}
Reply
#2

do a var_dump($recipes), check if there's something there and it has been passed in as whatever it is expecting object/array
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply
#3

hi @ignitedcms will you please guide for how to? i am following this tutorial site to Learn CI 4 , very beginner with zero experience.
regards
Reply
#4

What I would do is comment out lines 86 -88

then write <?php var_dump($recipes); ?>

First check if there's anything there.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply




Theme © iAndrew 2016 - Forum software by © MyBB