RE: read from text file problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
andylyon87
Forum Contributor
Posts: 168
Joined: Sat Jan 31, 2004 5:31 am
Location: Dundee

RE: read from text file problems

Post by andylyon87 »

hey guys
havin a bit of a problem with this code, it doesnt have errors but doesnt read the txt file :s

Code: Select all

$title = isset($title);
		$date = isset($date);
		$content = isset($content);
		
                $filename = "php/add.txt";
		$handle = fopen($filename, "r");
		$contents = fread($handle, filesize($filename));
		
                $line = explode("|", $contents);
			$line[0] = $title;
			$line[1] = $date;
			$line[2] = $content;
		
		echo "<p>".$title." -- Added on: ".$date."</p><p>".$content."</p><hr />";	
		fclose($handle);
The text file reads as follows:
test|19/03/05|blah blah balha ahuirgjerkb rierfihw jfwbnfi wfyq rfnweb rfi ffbqnf bq frqiufqbrfnqbrf qryfq rofq|
if anyone can see any problems please let me know thanks

Andy
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

Code: Select all

$line[0] = $title;
                        $line[1] = $date;
                        $line[2] = $content;
is backwards...

Code: Select all

$title = $line[0];
and this:

Code: Select all

$title = isset($title);
                $date = isset($date);
                $content = isset($content);
is useless.
andylyon87
Forum Contributor
Posts: 168
Joined: Sat Jan 31, 2004 5:31 am
Location: Dundee

Post by andylyon87 »

right oops ah well I knew it didnt look right at all. I think its gettin a bit late lol

thanks

Andylyon87
Post Reply