Jump to content

Archived

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

mkklepper

fgetcsv

Recommended Posts

I have a script that writes link info to a text file, this script reads and displays the information. Everything works bit I get this error  msg [b]Notice[/b]:Undefined index: 1 in [b]c:\inetpub\wwwroot\file\path.php on line 44[/b]
[code]
$display = "file\\path.txt";

if( is_file($file($display) ) {
$fp = @fopen("$display", 'rb');
    while( $line = @fgetcsv($fp, 100, "\t") ) {
    print"<div align=\"center\"><a href=\" $line[1] \"> $line[0] </a></div>";
    }
}
[/code]

Share this post


Link to post
Share on other sites
It most likely means that one of the lines in your file does not contain the delimiter -> \t, or the end of your file contains (2) empty lines after the last line with content! fgetcsv(), only allows for a single empty line after the last line with content!


Also what is this...

[code]if( is_file($file($display) ) {[/code]

it should be...

[code]if ( is_file ( $display ) {[/code]



me!

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.