Jump to content

Warning: Invalid argument supplied for foreach()


doodlebug

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??
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.