Web Design and Development Forums

[SOLVED] fread only reading 78 characters

This is a discussion on "[SOLVED] fread only reading 78 characters" within the PHP Forum section. This forum, and the thread "[SOLVED] fread only reading 78 characters are both part of the Program Your Website category.


Go Back   Webforumz.com > Program Your Website > PHP Forum

Welcome to Webforumz.com.
Register Now Register now!

Reply
 
LinkBack Thread Tools Rate Thread
Old Apr 5th, 2008, 19:58   #1 (permalink)
Nerdy Moderator
 
CloudedVision's Avatar
 
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 517
Blog Entries: 4
[SOLVED] fread only reading 78 characters

I'll give you a quick rundown:

  • Script downloads page from external server using CURL
  • CURL writes it to temp.xml
  • Use fopen to open temp.xml
  • Use fread to read temp.xml
Any reason why this is happening? I've checked temp.xml, and it has all the content in there. But fread only returns the first 78 characters. Why? It's worked fine in some other scripts. Here's a snippet of code:

PHP: Select all

function proxy($url) {
        
$ch curl_init($url); //CURL URL to temporary file
        
$fp = @fopen("temp.xml""w");
        
curl_setopt($chCURLOPT_FILE$fp); //I have no idea what this does
        
curl_setopt($chCURLOPT_HEADER0);
        
curl_exec($ch);
        
curl_close($ch);
        
fclose($fp);
        
$filename "temp.xml";
        
$fp fopen($filename"r"); //Read temporary file
        
$content fread($fpfilesize($filename));
        
fclose($fp);
        return 
$content;
    } 
__________________
Take it easy

Other Road Design

WebForumz Moderator: HTML | Javascript | PHP
CloudedVision is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Apr 7th, 2008, 10:28   #2 (permalink)
 
c010depunkk's Avatar
 
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 612
Blog Entries: 2
Send a message via MSN to c010depunkk
Re: fread only reading 78 characters

How about using file_get_contents().... Much simpler and I've never had problems with this function.
__________________
Web design is the creation of digital environments that facilitate and encourage human activity; reflect or adapt to individual voices and content; and change gracefully over time while always retaining their identity.

~ www.c010depunkk.com ~ the hang-out of a web developer

c010depunkk is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Apr 7th, 2008, 20:50   #3 (permalink)
Nerdy Moderator
 
CloudedVision's Avatar
 
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 517
Blog Entries: 4
Re: fread only reading 78 characters

Quote:
Originally Posted by c010depunkk View Post
How about using file_get_contents().... Much simpler and I've never had problems with this function.
I've already solved this problem, turns out it was not necessary to have cURL write to a temporary file, it could output the contents straight to a variable.

But thanks anyways, that tip will come in handy.
__________________
Take it easy

Other Road Design

WebForumz Moderator: HTML | Javascript | PHP
CloudedVision is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Reading a remote XML source in JavaScript jonbritton JavaScript Forum 2 Jan 25th, 2008 13:01
[SOLVED] making sure characters saved to db remain in the long version, like '£ cosmicbdog PHP Forum 3 Dec 1st, 2007 03:54
[SOLVED] Reading as text file backwards eon201 PHP Forum 4 Nov 8th, 2007 10:53
[SOLVED] Reading output. alexgeek PHP Forum 2 Oct 30th, 2007 00:41
[SOLVED] How To: Change characters in a textarea? Using Javascript Anonymous User JavaScript Forum 0 Feb 16th, 2005 12:34



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 10:52.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59