Joomla is failing on me!

Joined
May 9, 2011
Messages
98
Reaction score
2
Points
8
Location
Sewanee, TN
Your Mac's Specs
MacBook 13" 2.4 Intel Core 2 Duo 2 GB
So I've run into a problem with Joomla! I've posted on the joomla forums but nobody seems to answer me and I've gotten good responses from here before so hopefully someone can help me.

The problem is when I go to add any new content to the back-end of my joomla site, I can't do it. At the top of the page I'm getting three warnings that look like:

Warning: Invalid argument supplied for foreach() in /Applications/XAMPP/xamppfiles/htdocs/libraries/joomla/database/database/mysqli.php on line 727

Warning: Invalid argument supplied for foreach() in /Applications/XAMPP/xamppfiles/htdocs/libraries/joomla/database/database/mysqli.php on line 727

Warning: Invalid argument supplied for foreach() in /Applications/XAMPP/xamppfiles/htdocs/libraries/joomla/database/database/mysqli.php on line 727

So if I go to line 727 of the file it's giving me it says:

PHP:
/**
	 * Retrieves information about the given tables
	 *
	 * @param	array|string	A table name or a list of table names
	 * @param	boolean			Only return field types, default true
	 * @return	array	An array of fields by table
	 */
	public function getTableFields($tables, $typeonly = true)
	{
		settype($tables, 'array'); //force to array
		$result = array();

		foreach ($tables as $tblval) {
			$this->setQuery('SHOW FIELDS FROM ' . $tblval);
			$fields = $this->loadObjectList();

			if ($typeonly) {
				foreach ($fields as $field) {
					$result[$tblval][$field->Field] = preg_replace("/[(0-9)]/",'', $field->Type);
				}
			} else {
				foreach ($fields as $field) {
					$result[$tblval][$field->Field] = $field;
				}
			}
		}

		return $result;
	}

I don't know enough php to completely understand this but it's the last foreach that is causing the problems. I THINK it has to do with getting the values from the boxes where I type in the article title and whatnot. I'm probably wrong though...

and then if I try to fill out the new article and save it despite the warnings it says:

Save failed with the following error: Please provide a valid, non-blank title.

This is the second time I've had this problem. The first time it happened I googled and googled to find the answer and for the first time in a long time google failed me. So I did a fresh install of xampp and joomla! and made the sit again and now the same problem has come up. This is my first site building my own theme instead of just using the themes given to me by default. It's getting quite frustrating to tell my friend that her site is ready to go just to tell her it's broken again. I'm doing all of this locally on my computer for now, I was planning on putting the site online when we got everything finalized. Any help fixing this would be appreciated so that I can get my first real website online.
 
Joined
Mar 16, 2007
Messages
756
Reaction score
14
Points
18
have you tried to do a var_dump( $tables ) right before foreach? Might help to know what exactly $tables is.

You don't check, if settype actually works for you. The function returns a bool, so I would change the code to:

PHP:
if( settype($tables, 'array') )
{
   //for testing: 
   var_dump( $tables );

   $results = array();

   foreach( ... )
   {
      ...
   }
}
else
{
   //catch in case $tables cannot be set to array
   ...
}

Hope that helps!
 
OP
CaldwellYSR
Joined
May 9, 2011
Messages
98
Reaction score
2
Points
8
Location
Sewanee, TN
Your Mac's Specs
MacBook 13" 2.4 Intel Core 2 Duo 2 GB
I so wish that made sense... I don't know enough php to understand a word you're saying. That php came strait from the joomla mysqli.php file.
 
Joined
Mar 16, 2007
Messages
756
Reaction score
14
Points
18
I guess a php class is in order for you? :)

When did the problem start coming up? Did you modify any code anywhere or installed additional modules?

foreach expects an array, the function before (settype) is supposed to force the $table parameter into an array. But this function can fail too and in order to test this, settype returns a boolean. In your case I suspect that $tables is something that cannot be forced to an array (maybe it's even null) and foreach gets a type it cannot deal with. Hence my suggestions above.

Having said that: I didn't know the code you posted is actually Joomla core code. Usually you wouldn't want to mess around in there to make things work. Next time you'd upgrade your system all those core files get replaced and your changes are gone.

In that case I'd start further back and would check which of the changes you had recently made is calling this function and what type the first parameter is. Make sure it's an array.

I guess that's all help I can provide without actually having a look at the system :)
 
OP
CaldwellYSR
Joined
May 9, 2011
Messages
98
Reaction score
2
Points
8
Location
Sewanee, TN
Your Mac's Specs
MacBook 13" 2.4 Intel Core 2 Duo 2 GB
Thanks for the help! I haven't changed any core things but I'll go check out the extensions to see what could be causing the problems
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top