Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 05-30-2005, 03:34 PM php fopen help
Junior Talker

Posts: 3
Trades: 0
Hello,
I want to use a script so it will display on the webpage what is in a text document. I only want the first line and i am using this script.
<?php
$fp = fopen("stored/no6.txt", "r")
$data = fread($fp, 1);
fclose($fp);
echo $data;
?>
It comes up with this error "Parse error: parse error, unexpected T_VARIABLE in /home/randomsh/public_html/Submit.php on line 399"
and line 399 is this line: $data = fread($fp, 1);
Any ideas?
Many thanks
Chris Harris
harrishcris is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-31-2005, 01:55 AM
Experienced Talker

Posts: 32
Trades: 0
The code that you posted is just reading the first character if you want to read the first line try this

PHP Code:
function readfirstline($file){
   
$fp = @fopen($file"r");
   
$firstline fgets($fp);
   
fclose($fp);
   return 
$firstline;

I retrived the code from http://us2.php.net/fgets Check this site too when looking for ways to use function in php or any site that has the php manual

just in case you don't know the $file stands for the file path

so
PHP Code:

$file 
'home/test/go/try.txt';

readfirstline($file); 

Last edited by rcubes85; 05-31-2005 at 01:57 AM..
rcubes85 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to php fopen help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.30332 seconds with 12 queries