Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8
|
BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8
This is the forum to discuss the Wrox book Professional CodeIgniter by Thomas Myer; ISBN: 9780470282458
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 1st, 2010, 02:04 AM
Authorized User
 
Join Date: Jan 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to mehdymahmood
Default Invalid argument supplied for foreach() Filename: views/navigation.php

my getSubCategories function in mcats
function getCategoriesNav(){
$data = array();
$this->db->select('id,name,parentid');
$this->db->where('status', 'active');
$this->db->orderby('parentid','asc');
$this->db->orderby('name','asc');
$this->db->groupby('parentid,id');
$Q = $this->db->get('categories');
if ($Q->num_rows() > 0){
foreach ($Q->result() as $row){
if ($row->parentid > 0){
$data[0][$row->parentid]['children'][$row->id] = $row->name;

}else{
$data[0][$row->id]['name'] = $row->name;
}
}
}
$Q->free_result();
return $data;
}



my view/navigation

if (count($navlist)){
echo "<ul>";
foreach ($navlist as $key => $list){
foreach ($list as $topkey => $toplist){
echo "<li class='cat'>";
echo anchor("welcome/cat/$topkey",$toplist['name']);
echo "</li>\n";
if (count($toplist['children'])){
foreach ($toplist['children'] as $subkey => $subname){
echo "\n<li class='subcat'>";
echo anchor("welcome/cat/$subkey",$subname);
echo "</li>";
}
}
}
}
echo "</ul>\n";
}

my welcome/cat

function cat($id){
//$this->benchmark->mark('query_start');
$cat = $this->MCats->getCategory($id);
//$this->benchmark->mark('query_end');
if (!count($cat)){
redirect('welcome/index','refresh');
}
$data['title'] = "Claudia's Kids | ". $cat['name'];

if ($cat['parentid'] < 1){
//show other categories
$data['listing'] = $this->MCats->getSubCategories($id);
$data['level'] = 1;
}else{
//show products
$data['listing'] = $this->MProducts->getProductsByCategory($id);
$data['level'] = 2;

}
$data['category'] = $cat;
$data['main'] = 'category';
$data['navlist'] = $this->MCats->getCategoriesNav();
$this->load->vars($data);
$this->load->view('template');
}


when i load home page , its shows the following errors .


A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
# s
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
# S
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
#
A PHP Error was encountered

Severity: Notice

Message: Uninitialized string offset: 0

Filename: views/navigation.php

Line Number: 7
http://localhost/codeigniter2/index....e/cat/longdesc
A PHP Error was encountered

Severity: Notice

Message: Uninitialized string offset: 0

Filename: views/navigation.php

Line Number: 9
A PHP Error was encountered

Severity: Notice

Message: Uninitialized string offset: 0

Filename: views/navigation.php

Line Number: 10
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
# a
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
# 7
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
# 0
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
# 2
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
# s
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
# S
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
#
A PHP Error was encountered

Severity: Notice

Message: Uninitialized string offset: 0

Filename: views/navigation.php

Line Number: 7
http://localhost/codeigniter2/index....e/cat/longdesc
A PHP Error was encountered

Severity: Notice

Message: Uninitialized string offset: 0

Filename: views/navigation.php

Line Number: 9
A PHP Error was encountered

Severity: Notice

Message: Uninitialized string offset: 0

Filename: views/navigation.php

Line Number: 10
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
# a
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
# 7
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
# 0
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
# 3
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
# p
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
# S
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
#
A PHP Error was encountered

Severity: Notice

Message: Uninitialized string offset: 0

Filename: views/navigation.php

Line Number: 7
http://localhost/codeigniter2/index....e/cat/longdesc
A PHP Error was encountered

Severity: Notice

Message: Uninitialized string offset: 0

Filename: views/navigation.php

Line Number: 9
A PHP Error was encountered

Severity: Notice

Message: Uninitialized string offset: 0

Filename: views/navigation.php

Line Number: 10
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
# a
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
# 7
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
# 0
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
# 4
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
# d
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
# P
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
#
A PHP Error was encountered

Severity: Notice

Message: Uninitialized string offset: 0

Filename: views/navigation.php

Line Number: 7
http://localhost/codeigniter2/index....e/cat/longdesc
A PHP Error was encountered

Severity: Notice

Message: Uninitialized string offset: 0

Filename: views/navigation.php

Line Number: 9
A PHP Error was encountered

Severity: Notice

Message: Uninitialized string offset: 0

Filename: views/navigation.php

Line Number: 10
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
# i
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
# 7
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
# 0
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
# 5
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
# t
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
# T
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/navigation.php

Line Number: 10
#
A PHP Error was encountered

Severity: Notice

Message: Uninitialized string offset: 0

Filename: views/navigation.php

Line Number: 7
http://localhost/codeigniter2/index....e/cat/longdesc
 
Old February 17th, 2010, 05:13 PM
Registered User
 
Join Date: Feb 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default I'm having trouble with this code also

hmmmm.....





Similar Threads
Thread Thread Starter Forum Replies Last Post
[newbie] The E-mail supplied is invalid ? jon80 BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 7 July 20th, 2013 01:15 AM
Invalid argument supplied for foreach() codejockey Beginning PHP 4 September 24th, 2010 03:40 AM
warning..fetch_array(): supplied argument is not a valid msman88 MySQL 1 March 6th, 2009 07:11 AM
mailling list:mysql_num_rows(): supplied argument jamesz20 Beginning PHP 2 December 6th, 2006 11:45 AM
fwrite(): supplied argument is not a valid stream Adam H-W Beginning PHP 3 January 20th, 2006 02:09 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.