Invalid arguement supplied for a view?

Have a programming question regarding your component, plug-in, extension or core hacks? Have an interesting tidbit, FAQ or programming tip you’d like to share? This is the place for you.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Post Reply
Opie
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Thu Jun 22, 2006 7:32 pm
Contact:

Invalid arguement supplied for a view?

Post by Opie » Wed Oct 24, 2007 5:49 pm

I'm working on this new component to list currently active projects for my company.  The front end works on 1.5RC3 on a XAMPP server running on a WinXP machine.

However, when I bring it to work and install it, which it does without errors, it provides the following warnings / errors.  The office environment is a Win2k machine with IIS.

Warning: Invalid argument supplied for foreach() in ...\views\projects\tmpl\default.php on line 10


Line 10 of that file is

Code: Select all

<?php foreach ( $this->projects as $project ) : ?>


I'm assuming it is $this->projects that is the problem.

Any ideas for what I need to look into?
http://springhillalumni.org • Springhill High School Alumni Association

User avatar
ianmac
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 237
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: Invalid arguement supplied for a view?

Post by ianmac » Wed Oct 24, 2007 7:47 pm

Trace back to where $this->projects comes from and echo at various points along the way to figure out what is going wrong...

Presumably, $projects is not an array as it is supposed to be for foreach.

If that is in your layout, then go back into your view and make sure it gets assigned.  Then, check your model to see if something is going wrong there, and work back until you figure out what is failing.

Ian
Help test my Component XML Generator Tool!
http://extensions.joomla.org/component/option,com_mtree/task,viewlink/link_id,1997/Itemid,35/
All feedback appreciated!

Opie
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Thu Jun 22, 2006 7:32 pm
Contact:

Re: Invalid arguement supplied for a view?

Post by Opie » Thu Oct 25, 2007 1:11 pm

Thanks.  I'll post back if I can't find it from there.
http://springhillalumni.org • Springhill High School Alumni Association

Opie
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Thu Jun 22, 2006 7:32 pm
Contact:

Re: Invalid arguement supplied for a view?

Post by Opie » Thu Oct 25, 2007 8:15 pm

ianmac wrote:Trace back to where $this->projects comes from and echo at various points along the way to figure out what is going wrong...

Presumably, $projects is not an array as it is supposed to be for foreach.

If that is in your layout, then go back into your view and make sure it gets assigned.  Then, check your model to see if something is going wrong there, and work back until you figure out what is failing.

Ian
It seems this call is failing in my model.  The model is being called.

Code: Select all

$this->_data = $this->_getList($query);

Any ideas?  I have tried to model this on the weblinks core component.
http://springhillalumni.org • Springhill High School Alumni Association

User avatar
ianmac
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 237
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: Invalid arguement supplied for a view?

Post by ianmac » Thu Oct 25, 2007 8:19 pm

Have you tested to ensure that the query does work?

Ian
Help test my Component XML Generator Tool!
http://extensions.joomla.org/component/option,com_mtree/task,viewlink/link_id,1997/Itemid,35/
All feedback appreciated!

Opie
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Thu Jun 22, 2006 7:32 pm
Contact:

Re: Invalid arguement supplied for a view?

Post by Opie » Thu Oct 25, 2007 8:27 pm

ianmac wrote:Have you tested to ensure that the query does work?

Ian
The little things will get you.  Apparently, I need to work on my install.sql file for the installation.  The table was not created in the database.

At the end of my create table I have the following.

Code: Select all

ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;


When I try to create the table with phpMyAdmin, an error occurs regarding the CHARSET=utf8; portion.  Should I not have that in there?
http://springhillalumni.org • Springhill High School Alumni Association

User avatar
ianmac
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 237
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: Invalid arguement supplied for a view?

Post by ianmac » Thu Oct 25, 2007 8:31 pm

I dunno...  this is what I use:*

TYPE=MyISAM DEFAULT CHARSET=utf8 COLLATE `utf8_general_ci` AUTO_INCREMENT=1;


Ian


*I am not a database expert.  I know basics of SQL, and that is about it.  I don't even know joins that well, so, take that for what it is worth.
Help test my Component XML Generator Tool!
http://extensions.joomla.org/component/option,com_mtree/task,viewlink/link_id,1997/Itemid,35/
All feedback appreciated!

Opie
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Thu Jun 22, 2006 7:32 pm
Contact:

Re: Invalid arguement supplied for a view?

Post by Opie » Thu Oct 25, 2007 8:38 pm

ianmac wrote:I dunno...  this is what I use:*

TYPE=MyISAM DEFAULT CHARSET=utf8 COLLATE `utf8_general_ci` AUTO_INCREMENT=1;


Ian


*I am not a database expert.  I know basics of SQL, and that is about it.  I don't even know joins that well, so, take that for what it is worth.
You're ahead of me. ;)  It still did not work.  However, I don't see a need for this component in the general public as this is for internal use for my company's project list.  I'll have to look into this SQL issue at a later date.

Thanks for the help.
http://springhillalumni.org • Springhill High School Alumni Association

User avatar
ianmac
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 237
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: Invalid arguement supplied for a view?

Post by ianmac » Thu Oct 25, 2007 8:40 pm

What version of MySQL are you using?

Ian
Help test my Component XML Generator Tool!
http://extensions.joomla.org/component/option,com_mtree/task,viewlink/link_id,1997/Itemid,35/
All feedback appreciated!

Opie
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Thu Jun 22, 2006 7:32 pm
Contact:

Re: Invalid arguement supplied for a view?

Post by Opie » Thu Oct 25, 2007 9:03 pm

It's been so long since I installed, I can't remember.

It appears to be Server version 4.0.18 and Client version of 5.0.0.  Looks like I may need to update it.
http://springhillalumni.org • Springhill High School Alumni Association


Post Reply