Jump to content

Archived

This topic is now archived and is closed to further replies.

doodlebug

Warning: Invalid argument supplied for foreach()

Recommended Posts

Hi Board,

I'm afraid i'm pretty much a total newbie regarding php. I have aquired a link management script for which i can find no assistance with. I have installed it but i keep getting the following error message when i try to view the output page (links.php):

Warning: Invalid argument supplied for foreach() in /*******/local/home/****/loulousbijouterie.com/silver jewelry/FS_0930B/pages/linkman/links.php on line 44

The code for links.php is this:


error_reporting(E_ALL ^ E_NOTICE);

require "settings.php";
require_once("header.txt");

$lines = array ();
$lines=file($settings['linkfile']);

echo "<p class=\"linkman\">";

foreach ($lines as $thisline)
{
$thisline=trim($thisline);
if (!empty($thisline)) {
list($name,$email,$title,$url,$recurl,$description)=explode($settings['delimiter'],$thisline);
if ($settings['clean'] != 1) {$url="go.php?url=".$url;}
echo "<a href=\"$url\" target=\"_new\" class=\"linkman\">$title</a> - $description<br>\n";
}
}


Line 44 is the 'foreach ($lines as $thisline)' line, but i can't see the problem.

Any ideas anyone??

Share this post


Link to post
Share on other sites
After this line [code]<?php $lines=file($settings['linkfile']); ?>[/code] add the debugging line [code]<?php echo '<pre>' . print_r($lines,true) . '</pre>'; ?>[/code] to see whether the variable $lines is an array and what it contains.

Ken

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.