February 25, 2020, 03:13:06 am
News: If someone gives you assistance give them a Good Star
Pages: [1]   Go Down
Author Topic: Lost Topic Title  (Read 638 times)
Mushroom Realm
Full Member
*

Stars: +0/-0
Offline Offline

Posts: 205



WWW
« on: August 30, 2003, 09:52:53 pm »

When I try to use the echo statment in this file it gives me this error: Parse error: parse error, unexpected T_ECHO in /web/https-mushroom/docs/lyrics.php on line 10.  Heres the whole file:
Code:
<?php
$handle;
$desc;
$handle=fopen("/web/https-mushroom/docs/def_hexagram.txt","r");
while(!feof($handle)){
$desc=fgets($handle);
}
fclose($handle)
echo $desc;
?>

I used echo in another file and it worked fine.  Although the only thing in the other file was the echo statement.  Anybody know whats wrong?
Logged

Mushroom

Gimlin
Supporters
*

Stars: +0/-0
Offline Offline

Posts: 1430



WWW
« Reply #1 on: August 30, 2003, 10:00:15 pm »

fclose($handle) does not have a semi colon.

fclose($handle);
Logged

[span style=\'color:blue\']"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."[/span]

Mushroom Realm
Full Member
*

Stars: +0/-0
Offline Offline

Posts: 205



WWW
« Reply #2 on: August 31, 2003, 02:05:27 am »

doh Thanks Gimlin
Logged

Mushroom

Mushroom Realm
Full Member
*

Stars: +0/-0
Offline Offline

Posts: 205



WWW
« Reply #3 on: August 31, 2003, 02:20:01 am »

A new slightly related problem has come up.  With that code it only display the last line of the file.  I tried moving the echo into the loop, but that got rid of the line breaks and just wrote it all out.  How can I get it to either display it just the way the file is, or place a new line onto the page?
Logged

Mushroom

Mushroom Realm
Full Member
*

Stars: +0/-0
Offline Offline

Posts: 205



WWW
« Reply #4 on: August 31, 2003, 02:28:59 am »

Okay, I figured it out.  It was writing the page exactly how it was in the file, but thats not how explorer displays it.
Logged

Mushroom

da_silvy
Newbie
*

Stars: +0/-0
Offline Offline

Posts: 2


WWW
« Reply #5 on: August 31, 2003, 05:23:44 am »

Code:
<?php
$handle;
$desc;
$handle=fopen("somefile.txt","r");
while(!feof($handle)){
$desc .= htmlspecialchars(fgets($handle)) . "<br>";
}
fclose($handle);
echo $desc;
?>

How about something like that :o?
Logged

Pages: [1]   Go Up
Print
 
Jump to: