[SOLVED] Reading from a text file ~ displays 2 times

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
worm5252
Forum Newbie
Posts: 5
Joined: Mon Jan 24, 2005 12:55 pm

[SOLVED] Reading from a text file ~ displays 2 times

Post by worm5252 »

Code: Select all

<?php
    $listFile = "latest.txt";
    if (!($fp = fopen($listFile, "r")))  
        exit("Unable to open the input file, $listFile.");
    $buffer = fread($fp, filesize($listFile));  
    print "$buffer<br>\n";  
    fclose($fp);
?>
<html>
<body bgcolor="4D5E6B">
<?php echo $buffer; ?>
</body>
</html>
This is displaying the contents of my text files 2 times, I only want it to display 1 time? any ideas?
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Either remove

Code: Select all

print "$buffer<br>\n";
...or...

Code: Select all

<?php echo $buffer; ?>
Preferably the first.
worm5252
Forum Newbie
Posts: 5
Joined: Mon Jan 24, 2005 12:55 pm

Post by worm5252 »

That was it, thanks man, I didn't even notice that
Post Reply