Page 1 of 1

RE: read from text file problems

Posted: Mon Mar 19, 2007 6:33 pm
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

Posted: Mon Mar 19, 2007 6:59 pm
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.

Posted: Mon Mar 19, 2007 7:35 pm
by andylyon87
right oops ah well I knew it didnt look right at all. I think its gettin a bit late lol

thanks

Andylyon87