Page 1 of 1

Having a problem with this script

Posted: Wed Oct 04, 2006 9:00 am
by studio727
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I am building a link directory for myself to exchange links with everyone, and I downloaded the program, it successfully installed, and it's not working. Do you see what is wrong with the code?


Here's the error:

Code: Select all

Warning: Invalid argument supplied for foreach() in /home/froshizz/public_html/directory/category.php on line 125

Here's the code from line 125 on down:

Code: Select all

foreach ( $result as $val )
	{
	// don't build a directory if there is no sub directory for this category
	if ( $val->sub_category == "" )
		{
		continue;
		}

	$sub_category = str_replace ( "_", " ", $val->sub_category );
	show_category_row ( $category, $sub_category, $val->sub_category );
	$count++;
	if ( $count == $round )
		{
		echo "</table>\n";
		echo "<td width=\"50\">&nbsp;</td>\n";
		echo "<td width=\"250\" valign=\"top\">\n";
		echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
		}
	}


echo "</table>\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<p>\n";

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Wed Oct 04, 2006 9:01 am
by volka
Here's the code from line 125 on down:
interesting, but what is $result? ;)
There's probably some code like $result = xyz();

Posted: Wed Oct 04, 2006 9:13 am
by studio727

Code: Select all

$result		= $db->get_results ( $query );
This is what I found

Posted: Wed Oct 04, 2006 2:47 pm
by feyd
The error would suggest $result isn't an array. Therefore I can only assume that $db->get_results($query) returned a failure code or something other than an array. var_dump() may be useful here as a debugging helper.