[PHP] fread() memory problems

2009-11-15 Thread Ashley Sheridan
I was just wondering why fread() seems to use so much memory when reading in a file. My php.ini has a script memory limit of 32MB, yet PHP hits its memory limit on a 19MB mbox file that I'm reading in. How is it possible that this function can use 150% of a files' size in memory?! Thanks, Ash htt

Re: [PHP] fread question

2008-12-18 Thread MikeP
you have magic_quotes_runtime turned on LOCALLY. Use phpinfo() to see. NOmagic_quotes_runtime Off you actually managed to put the backslashes into your text file. NO . . . . ,/()%...@!',''); //fix special chars in name $_POST[$fname.'_fname'] = strtr($_POST[$fname.'

Re: [PHP] fread question

2008-12-18 Thread ceo
PHP does *not* do the addslashes on $_POST when you cram something into it in your PHP code. It does it during the process of auto-filling up $_POST. So either: A) you have magic_quotes_runtime turned on LOCALLY. Use phpinfo() to see. B) you actually managed to put the backslashes into yo

RE: [PHP] fread question

2008-12-18 Thread Boyd, Todd M.
Hah! Forgot to add the link: 1. http://php.net/ini_set How would you guys have ever figured out that was the page on PHP's website you need to visit in order to view information about the ini_set() function?! ;) // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe,

RE: [PHP] fread question

2008-12-18 Thread Boyd, Todd M.
> -Original Message- > From: MikeP [mailto:mpel...@princeton.edu] > Sent: Thursday, December 18, 2008 7:33 AM > To: php-general@lists.php.net > Subject: Re: [PHP] fread question > > Still having problems: > magic_quotes_runtime is off > BUT > magic_quotes_

Re: [PHP] fread question

2008-12-18 Thread MikeP
Still having problems: magic_quotes_runtime is off BUT magic_quotes_gpc is on I cant change them myself so I tried stripslashes That doesnt work though: $_POST[$fname] = fread($fileHandle, $_POST[$fname.'_size']); $test=$_POST[$fname]; $test3=stripslashes($test); $test3 and $test are the

Re: [PHP] fread question

2008-12-18 Thread MikeP
But this one is ON magic_quotes_gpc "Robert Cummings" wrote in message news:1229567238.8302.35.ca...@localhost... > On Wed, 2008-12-17 at 19:54 -0500, MikeP wrote: >> Hello, >> I have been trying to use fread to open a file, but it always escapes >> special characters. >> How do I open afile wit

Re: [PHP] fread question

2008-12-18 Thread MikeP
>From my phpinfo: magic_quotes_runtime Off "Robert Cummings" wrote in message news:1229567238.8302.35.ca...@localhost... > On Wed, 2008-12-17 at 19:54 -0500, MikeP wrote: >> Hello, >> I have been trying to use fread to open a file, but it always escapes >> special characters. >> How do I o

Re: [PHP] fread question

2008-12-17 Thread Robert Cummings
On Wed, 2008-12-17 at 19:54 -0500, MikeP wrote: > Hello, > I have been trying to use fread to open a file, but it always escapes > special characters. > How do I open afile without it modifying my original file: > > $_POST[$fname] = fread($fileHandle, $_POST[$fname.'_size']); > I use this and ge

[PHP] fread question

2008-12-17 Thread MikeP
Hello, I have been trying to use fread to open a file, but it always escapes special characters. How do I open afile without it modifying my original file: $_POST[$fname] = fread($fileHandle, $_POST[$fname.'_size']); I use this and get slashes everywhere.This kills my REGex that gets coded next

Re[2]: [PHP] fread() behaviour

2008-11-28 Thread ANR Daemon
Greetings, Jochem Maas. In reply to Your message dated Thursday, November 20, 2008, 22:11:09, > good stuff from Stut & Craige ... I just wondered, Im pretty sure that the > usleep(1000) is completely superfluous. fread() will read to the buffer length > or EOF regardless of how slow the stream tri

Re: [PHP] fread() behaviour

2008-11-20 Thread Jochem Maas
Stut schreef: > On 20 Nov 2008, at 01:29, Rene Fournier wrote: >> I'm trying to understand something about fread(). I'm using fread() on >> an incoming socket stream that will send, for example, 26630 characters: >> >> while ( ($buf=fread($read[$i], 8192)) != '' ) { >> $sock_data .= $buf; >>

Re: [PHP] fread() behaviour

2008-11-20 Thread Stut
On 20 Nov 2008, at 01:29, Rene Fournier wrote: I'm trying to understand something about fread(). I'm using fread() on an incoming socket stream that will send, for example, 26630 characters: while ( ($buf=fread($read[$i], 8192)) != '' ) { $sock_data .= $buf; usleep(1000);

Re: [PHP] fread() behaviour

2008-11-19 Thread Craige Leeder
Rene Fournier wrote: So my question is, why does fread wait if there is nothing more to read? Shouldn't it return immediately? (That's what I want.) And as for the delay, it's there so that if the incoming data is a little slow, it has time to catch up with fread. Thanks. ...Rene I do belie

[PHP] fread() behaviour

2008-11-19 Thread Rene Fournier
I'm trying to understand something about fread(). I'm using fread() on an incoming socket stream that will send, for example, 26630 characters: while ( ($buf=fread($read[$i], 8192)) != '' ) { $sock_data .= $buf; usleep(1000); echo "."; } echo ","; As soon as th

Re: [PHP] fread problem

2006-01-04 Thread Curt Zirzow
On Mon, Jan 02, 2006 at 09:35:21PM +0100, Mario de Frutos Dieguez wrote: > Hi! > > I have a problem using fread with a XML document. When i read some nodes > with a great amount of text it cuts in the same place of the text. There > are any limitation of text or something? I have in the php.ini th

[PHP] fread problem

2006-01-02 Thread Mario de Frutos Dieguez
Hi! I have a problem using fread with a XML document. When i read some nodes with a great amount of text it cuts in the same place of the text. There are any limitation of text or something? I have in the php.ini the amount of memory in 256M. Thanks in advance -- PHP General Mailing List (http:

Re: [PHP] fread and fgets (network streams)

2005-09-04 Thread The Gimper
Sorry for the bump, but please anyone? :P Quoting The Gimper <[EMAIL PROTECTED]>: > On the php.net you can read the following about fread: > > "fread() reads up to length bytes from the file pointer referenced by > handle. > Reading stops when length bytes have been read, EOF (end of file) is >

[PHP] fread and fgets (network streams)

2005-09-01 Thread The Gimper
On the php.net you can read the following about fread: "fread() reads up to length bytes from the file pointer referenced by handle. Reading stops when length bytes have been read, EOF (end of file) is reached, or (for network streams) when a packet becomes available, whichever comes first." I

[PHP] fread is allocating memory on its own?

2005-03-26 Thread Ficos
I'm trying to use a PHP script to test the throughput from a few different web servers on a test network at work. I'm doing an fopen with the URL, and then a read loop like this: while (!feof($handle)) { fread($handle, 8192); } I'm ignoring the data returned by fread, since I'm just int

Re: [PHP] fread()

2004-12-09 Thread Richard Lynch
Russell P Jones wrote: > Is there any way to use fread() or a similar function to read a section of > a document NOT starting at the beginning... > > for example, I can read the first 1000 bytes of a document with > > fread($doc, 1000); > > Is there any way to read the second 1000 bytes? > > perhap

RE: [PHP] fread()

2004-12-08 Thread Justin Palmer
( http://www.google.com ); Archives::getUri( http://marc.theaimsgroup.com/?l=php-general ); -Original Message- From: Russell P Jones [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 08, 2004 12:20 PM To: [EMAIL PROTECTED] Subject: [PHP] fread() Is there any way to use fread() or a similar functio

[PHP] fread()

2004-12-08 Thread Russell P Jones
Is there any way to use fread() or a similar function to read a section of a document NOT starting at the beginning... for example, I can read the first 1000 bytes of a document with fread($doc, 1000); Is there any way to read the second 1000 bytes? perhaps, fread($doc, 1000, 2000); who knows..

[PHP] fread error

2004-07-08 Thread Don
Hi, Using a a flat text file based calendar script. Started getting this error after upgrading PHP: Warning: fread(): Length parameter must be greater than 0 Function it is occurring in is: function read_str($fp) { $strlen = $this->bin2dec(fread($fp,4),4); return fread($fp, $strlen);

[PHP] fread(): SSL: fatal protocol error

2003-08-28 Thread Ray Van Dolson
I'm running PHP 4.3.3 compiled with --with-openssl against Red Hat 8.0's latest OpenSSL libraries (patched versions of 0.9.6) and am having some strange issues using fopen(), fread() and friends. Here's my code: function echo_test() { $opts = array( 'ssl' => array( '

[PHP] fread() question

2003-07-11 Thread Seairth Jacobs
I have an open socket that I am reading from. The code looks like the following: $contentLength = 0 + $this->response['headers']['content-length']; do{ $status = socket_get_status($this->socket); if( $status['eof'] == 1 ) { if( $this->clientOptions['debug'] & DBGSOCK ) echo("DBG

[PHP] fread has changed functionality...please read

2003-06-13 Thread Bob Silva
Just wanted to let everyone else know so they don't waste days trying to figure it out. When using fread() on just about anything except for a file, it only reads one packet at a time. This means you must fread within a loop to read the bytes you need. You can no longer pass "$length bytes to be r

Re: [PHP] fread or not?

2003-03-05 Thread Jason Wong
On Thursday 06 March 2003 11:41, John Taylor-Johnston wrote: > I need to upoload a local text file into memory using: > > > The script below will only work if I am using my localhost. > > Any ideas? What happens when you're NOT using localhost? And as this is an upload problem, try searching the

[PHP] fread or not?

2003-03-05 Thread John Taylor-Johnston
I need to upoload a local text file into memory using: The script below will only work if I am using my localhost. Any ideas? John \n"; if (!$filename) { echo "!\$filename \n"; }else{ #$filename = "/usr/local/something.txt"; #echo "\$filename $filename\n"; $handle = fopen ($filename, "r");

Re: [PHP] fread problem

2003-03-03 Thread Ernest E Vogelsinger
At 05:46 03.03.2003, Paul Cohen said: [snip] >Here is the code in my file and was taken directly from the manual: > >$filename = "test.php"; >$handle = fopen ($filename, "r"); >$contents = fread ($handle, filesize ($filename)); >fclose ($handl

RE: [PHP] fread problem

2003-03-02 Thread John W. Holmes
> I am trying to read a php file to a varible and then print that variable. > Unfortunately, my php file is not being parsed by the fread function and I > can't figure out why. > > Here is the code in my file and was taken directly from the manual: > > $filename = "test.php"; > $handle =

RE: [PHP] fread problem

2003-03-02 Thread Martin Towell
From: Paul Cohen [mailto:[EMAIL PROTECTED] > Sent: Monday, March 03, 2003 3:46 PM > To: [EMAIL PROTECTED] > Subject: [PHP] fread problem > > > Hello all, > > I am trying to read a php file to a varible and then print > that variable. > Unfortunately, my php file is not b

[PHP] fread problem

2003-03-02 Thread Paul Cohen
Hello all, I am trying to read a php file to a varible and then print that variable. Unfortunately, my php file is not being parsed by the fread function and I can't figure out why. Here is the code in my file and was taken directly from the manual: $filename = "test.php"; $handle = fope

[PHP] fread vs fgets

2003-02-02 Thread Jeff Schwartz
I'm trying to download various amount of information from handles opened by fsockopen. fgets works but takes forever on very large files because it breaks on every line. fread seems like it would work better but when I use a buffer of 1024 or 4096, it's actually far SLOWER on small files. Wha

Re: [PHP] fread() fails with large files

2002-11-03 Thread rija
;); readfile($file); - Original Message - From: "Sora B. Harbater" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, November 04, 2002 12:44 AM Subject: [PHP] fread() fails with large files > Hi. I am using Linux/Apache with PHP 4.1.2. I have been experi

[PHP] fread() fails with large files

2002-11-03 Thread Sora B. Harbater
Hi. I am using Linux/Apache with PHP 4.1.2. I have been experiencing this problem since upgrading from an earlier version of PHP 4. My script forces a download of a PDF file after looking up some info in a database. The code looks like this: $file="/path/to/file"; $fp = fopen($file, "r"); $

Re: [PHP] fread & EOF

2002-10-29 Thread Marek Kilimajer
Would not be closing the conection in the perl script enough? Martin Adler wrote: Hi, this php-script should read from a server (that i've written in perl) until it receives the EOF signal. My server sends the EOF-signal by print $client "\n\004"; # \004 = EOF to my script but fread would

[PHP] fread & EOF

2002-10-28 Thread Martin Adler
Hi, this php-script should read from a server (that i've written in perl) until it receives the EOF signal. My server sends the EOF-signal by print $client "\n\004"; # \004 = EOF to my script but fread wouldn't stop reading and i don't have any ideas why. Is php using an other sign for EOF?

[PHP] fread() function do not read first two lines

2002-06-28 Thread adi
Hi! Why fread() function do not read first two lines in a file? I have a chrates.php file : Title here! PS.rates.php is: '6.5596', 'ADP' => '183.180', 'AED' => '3.6725', 'AFA' => '4750.00', 'ALL' => '143.840', 'ANG' => '1.7800', 'AON' => '5.8956

Re: [PHP] fread and session vars

2002-05-27 Thread Zac Hillier
res a session variable. Zac - Original Message - From: "John Holmes" <[EMAIL PROTECTED]> To: "'Zac Hillier'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Monday, May 27, 2002 7:12 PM Subject: RE: [PHP] fread and session vars > Hi. > &g

RE: [PHP] fread and session vars

2002-05-27 Thread John Holmes
Hi. > Code: > > generate page script: > > $pge = create-page.php > $pd = $HTTP_GET_VARS['pd']; > > # Set the files > $crtPge = "/". $pge ."?pd=". $pd; # the url of the dynamic page to write > the > output page > $targetfilename = $SITE_ DOCUMENT_ROOT . $outPge; # the output page > > # delete

Re: [PHP] fread and session vars

2002-05-27 Thread Zac Hillier
p.html') . " for writing. Static page update aborted!"); exit(); } #write to temp file fwrite($tempfile, $htmldata); # close the temp file fclose($tempfile); etc... === create-page.php: To: "'Zac Hillier'&qu

RE: [PHP] fread and session vars

2002-05-27 Thread John Holmes
Post some code. I don't understand completely what you're trying to do or how you're trying to do it. ---John Holmes... > -Original Message- > From: Zac Hillier [mailto:[EMAIL PROTECTED]] > Sent: Monday, May 27, 2002 9:20 AM > To: [EMAIL PROTECTED] > Su

[PHP] fread and session vars

2002-05-27 Thread Zac Hillier
Hi all, I'm using the fread function to read one of my php scripts and then produce a static page, within this script I'm using session variables. If I browse to the script normally then all appears to work correctly, however when I use the fread function the session variables are not being tr

[PHP] fread + binary file

2002-01-27 Thread Michael Agbaglo
Hello ! I've some tourble w/ the following piece of code. The file to read doesn't contain zeros at the beginning, but the output is a= 0 b=0 is there a problem w/ fread ? (php 4.0.6, RedHat 7.2) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED

[PHP] fread (with fsockopen) returns nothing for CGI file

2001-08-06 Thread James Crowley
Hi, I am using fsockopen and fread to get the contents of a file on a server. Everything seems to work fine, except for one url. Opening http://ad-adex3.flycast.com/server/img/3327812_VBWeb/11196014_Restofsite /999 Works fine, however, http://www.burstnet.com/cgi-bin/ads/ad8747a.cgi?uniq=9

[PHP] fread from /dev/ttyS0 without EOF

2001-07-04 Thread Tobias Fritz
Hi, I have a GSM modem connected to /dev/ttyS0 and would like to use php to communicate with the modem. Writing works perfectly like this: $fp=fopen("/dev/ttyS0","r+"); fwrite($fp,"AT+CMGL\r"); but reading is a little problem because if the modem for example answers to the "AT+CMGL" message I s

[PHP] fread via ftp to NT fails

2001-05-21 Thread Mark Heintz PHP Mailing Lists
I'm attempting to read a file from a remote server and save it to a variable. The code below works fine if the remote server is unix based, but fails with the server I actually need to retrieve data from (NT4 SP4, beyond my control). When trying to fread from the NT server, $invoice_contents en

Re: [PHP] fread over ftp

2001-02-23 Thread Richard Lynch
> if( !($fd = @fopen($ftp_url, "r")) ){ > $error = true; > $error_msg = "Unable to connect to server."; > } > else { > $file_contents = fread($fd, 10); > fclose($fd); > } > > if( empty($file_contents) ){ > $error = true; > $error_msg = "Did not read file."; > } > > > The problem is

[PHP] fread over ftp

2001-02-21 Thread Mark Heintz PHP Mailing Lists
I'm having some trouble reading a text file from a remote server into a string. The code is as follows: if( !($fd = @fopen($ftp_url, "r")) ){ $error = true; $error_msg = "Unable to connect to server."; } else { $file_contents = fread($fd, 10); fclose($fd); } if( empty($file_content

Re: [PHP] fread strangeness (was: nested echo and includes, mixedhtml / PHP)

2001-02-19 Thread Jaxon
David - very cool, thanks much for your help! if any other newbies run into the same problem: echo "stuff"; //prints "stuff" echo $string; //prints contents of string, does NOT parse. include(filename); //whenever encountered, prints contents of file //parses only if PH

Re: [PHP] fread strangeness (was: nested echo and includes, mixed html / PHP)

2001-02-19 Thread David Robley
On Tue, 20 Feb 2001 11:37, Jaxon wrote: > Same problem, found it's coming from somewhere else :( > It looks as if fread or fopen is preventing PHP from from parsing ... > > index.php: > > $file="test.inc"; > $fd = fopen ($file, "r"); > $string = fread ($fd, filesize ($file)); > fclose ($fd); > ec

[PHP] fread strangeness (was: nested echo and includes, mixed html /PHP)

2001-02-19 Thread Jaxon
Same problem, found it's coming from somewhere else :( It looks as if fread or fopen is preventing PHP from from parsing ... index.php: test.inc: index.html show a blank html page, with the contents of test.inc visible via view source...grr. how can I get it to actually parse the PHP?

Re: [PHP] fread() a remote file

2001-02-09 Thread Jason Stechschulte
On Fri, Feb 09, 2001 at 09:02:04AM -0600, Tyler Longren wrote: > Could you perform fread() on a remote file? Yes I could, and so can you, so why not try it? An example: $handle = fopen("http://www.php.net/manual/en/function.fread.php", "r"); while($line = fread($handle, 255)) { echo "$line";

[PHP] fread() a remote file

2001-02-09 Thread Tyler Longren
Hello everybody, Could you perform fread() on a remote file? Example: $file = fopen("http://www.myurl.com/test.html", "rb"); $data = fread($file, filesize('http://www.myurl.com/test.html')); ??? Thanks! Tyler Longren -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [