PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Downloaded a joomla blog pluggin and received the following invalid foreach() statement:
Warning: Invalid argument supplied for foreach() in /home/fhlinux161/f/fluidtestsite.co.uk/user/htdocs/components/com_idoblog/assets/templates/idobloger/comment.php on line 2
May not be the full issue you're experiencing but you need to add a curly brace to line 2. Any code to be executed during the foreach needs to go in between them (assuming there will be any), and there was only a closing curly brace in what you pasted.
The problem is simply that the $this->comments is not an iteratable object. Probably because it was not set, or maybe because of an error in the pluggin... You have to report this to the pluggin developper!
It all depends where the $comment is located. It could be a __get magic function that returns this info, or it could be a property of an object. Either way, you first need to learn that something that is not set will get set to '' or NULL if you use it.
Doing echo $comments return nothing because you just set the value that probably did not exist.
What you need to do is either:
var_dump($this->comments) or var_dump($objectname->comments) to be able to display the real current value of the comments property!