Re: [PHP] Reading binary file data into variable
I have one for windows, think it works with PHP4 aswell, not sure where i put it so let me know if you require it and Ill dig it up? problem is it wont work on Linux. Jay Blanchard wrote: [snip] Did you try using fopen's binary safe read? Something like : [/snip] Shy of being able to do this in the way that I imagined, does anyone know of a class (not requiring PHP 5, as one does on phpclasses.org) that will allow me to specify several PDF and/or other files in a directory to be zipped up so that the archive can be unzipped by the great unwashed at some point? TVMIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Reading binary file data into variable
I am following Coggeshall's article on Zend for creating ZIP files. I seem to have run into a problem with PDF's though. In his code you have to read the file into a variable. I have tried file_get_contents, readfile, a combination of fopen, fpassthru, etc $filedata = readfile(INVOICEDIR.AOM.1075.542.54243641075B05130.pdf); The next line in this little jewel runs the data through the ZIP routines, $zipfile-add_file($filedata, tempzip/AOM.1075.542.54243641075B05130.pdf); I stayed up too late last night and got up too early this morning, so I am just brain-farting on what I should do here. How do I get (or can I get) the PDF data into the variable so that it comes out smelling like a rose on the other end of the train where the ZIP file get opened and the individual files are exapndable? BTW, I have tested this with text too. I am having some problems there as well, because file_get_contents seems to leave things 'short'. However, if I fopen the text file and read the text into a variable I can do the output side. I appreciate any and all insight into this problem, even Nichel's :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reading binary file data into variable
Jay Blanchard wrote: I am following Coggeshall's article on Zend for creating ZIP files. I seem to have run into a problem with PDF's though. In his code you have to read the file into a variable. I have tried file_get_contents, readfile, a combination of fopen, fpassthru, etc $filedata = readfile(INVOICEDIR.AOM.1075.542.54243641075B05130.pdf); The next line in this little jewel runs the data through the ZIP routines, $zipfile-add_file($filedata, tempzip/AOM.1075.542.54243641075B05130.pdf); I stayed up too late last night and got up too early this morning, so I am just brain-farting on what I should do here. How do I get (or can I get) the PDF data into the variable so that it comes out smelling like a rose on the other end of the train where the ZIP file get opened and the individual files are exapndable? BTW, I have tested this with text too. I am having some problems there as well, because file_get_contents seems to leave things 'short'. However, if I fopen the text file and read the text into a variable I can do the output side. I appreciate any and all insight into this problem, even Nichel's :) Did you try using fopen's binary safe read? Something like : $binary_data = ; $fp = fopen ( $file, rb ); while ( ! feof ( $fp ) ) { $binary_data .= fgets ( $fp ); } fclose ( $fp ); Don't know if it will work (or if you already tried it)...more like a guess. PS don't trust that Nichel guy, he's really a HTML monkey using Front Page. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Reading binary file data into variable
[snip] Did you try using fopen's binary safe read? Something like : $binary_data = ; $fp = fopen ( $file, rb ); while ( ! feof ( $fp ) ) { $binary_data .= fgets ( $fp ); } fclose ( $fp ); Don't know if it will work (or if you already tried it)...more like a guess. [/snip] Yes, tried that. It throws an error when trying to open the ZIP file missing 1 byte in Zip File... [snip] PS don't trust that Nichel guy, he's really a HTML monkey using Front Page. [/snip] But I think I can make him buy us all a beer one day. BTW, even though this is Texas I found some Dixie the other daymm delicious Dixie Beer. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Reading binary file data into variable
[snip] Did you try using fopen's binary safe read? Something like : [/snip] Shy of being able to do this in the way that I imagined, does anyone know of a class (not requiring PHP 5, as one does on phpclasses.org) that will allow me to specify several PDF and/or other files in a directory to be zipped up so that the archive can be unzipped by the great unwashed at some point? TVMIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] reading txt file - certain lines
Dustin Krysak wrote: snip Now what I want to do is read this file, but only say read 5 songs worth, then I would place the PHP code in (another table) and display the next 5 songs and so on This just allows for a more flexible layout in the final presentation. the way I am having the text files written, there is no way to get it to produce seperate text files - otherwise this would be easy to do snip What you can do (if you have access to a DB) is pull the text file into a single field table, using br as the line terminator. Looking at my MySQl book, for LOAD DATA, it says you can use a string to terminate the line. Then you can just run a simple query on the table (limited to the equivalent lines for 5 songs), and together with a loop, output the results. For big files, the DB will be faster and provides you with far greater flexibility HTH -- Rory McKinley Nebula Solutions +27 21 555 3227 - office +27 21 551 0676 - fax +27 82 857 2391 - mobile www.nebula.co.za This e-mail is intended only for the person to whom it is addressed and may contain confidential information which may be legally privileged. Nebula Solutions accepts no liability for any loss, expense or damage arising from this e-mail and/or any attachments. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] reading txt file - certain lines
Everything is possible :) And in this case, it seems, that lines are delimited by br ... i'm not quite sure, whether br can be used in explode as a delimiter, if so, you have no problem and you just read all the file into variable, $lines = explode('br', $variable) and you have lines in $lines... if br can not be explode's parameter, i would use str_replace to replace it with ie. #13 and then explode it... or use some regular expressions... it depends on how fast you need it... :) hope this was what you needed... :) regards, m. Dustin Krysak wrote: Hi there.. .I am displaying info (on music) from a text file with the following code... ?php //open the file handler $fp02=fopen(assets/lib/php/itunes/recent.txt,r); //Read the track info $recent=fgets($fp02); //close the file. echo $recent; fclose($fp02); ? Now the contents of said text file would read something like the following: bLiar/bbrby ibSex Pistols/bibriNever Mind The Bollocks/ibrPlayed: 2004/07/28, 1:48:29 PMbr--brbLet's Rave On/bbrby ibThe Raveonettes/bibriChain Gang Of Love/ibrPlayed: 2004/07/28, 1:46:37 PMbr--brbNo Remorse/bbrby ibMetallica/bibriKill 'Em All/ibrPlayed: 2004/07/28, 1:40:17 PMbr--brbThis Is Our Emergency/bbrby ibPretty Girls Make Graves/bibriThe New Romance/ibrPlayed: 2004/07/28, 1:36:37 PMbr--brbFreestylin'/bbrby ibGreyboy/bibriFreestylin'/ibrPlayed: 2004/07/28, 1:30:25 PMbr--brbIn My Head/bbrby ibNaked Raygun/bibriRaygun...Naked Raygun (Reissue)/ibrPlayed: 2004/07/28, 1:26:37 PMbr--brbLust To Love/bbrby ibThe Go-Go's/bibriReturn To The Valley Of The Go-Go's/ibrPlayed: 2004/07/28, 1:23:13 PMbr--brbKim You Bore Me To Death/bbrby ibGrandaddy/bibriConcrete Dunes/ibrPlayed: 2004/07/28, 1:18:37 PMbr--brbSonderkommando/bbrby ibGwar/bibriThis Toilet Earth/ibrPlayed: 2004/07/28, 1:13:49 PMbr--br Now what I want to do is read this file, but only say read 5 songs worth, then I would place the PHP code in (another table) and display the next 5 songs and so on This just allows for a more flexible layout in the final presentation. the way I am having the text files written, there is no way to get it to produce seperate text files - otherwise this would be easy to do Is this possible? Thanks in advance! Dustin -- Miroslav Hudak developer designer http://hudak.info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] reading txt file - certain lines
Hi there.. .I am displaying info (on music) from a text file with the following code... ?php //open the file handler $fp02=fopen(assets/lib/php/itunes/recent.txt,r); //Read the track info $recent=fgets($fp02); //close the file. echo $recent; fclose($fp02); ? Now the contents of said text file would read something like the following: bLiar/bbrby ibSex Pistols/bibriNever Mind The Bollocks/ibrPlayed: 2004/07/28, 1:48:29 PMbr--brbLet's Rave On/bbrby ibThe Raveonettes/bibriChain Gang Of Love/ibrPlayed: 2004/07/28, 1:46:37 PMbr--brbNo Remorse/bbrby ibMetallica/bibriKill 'Em All/ibrPlayed: 2004/07/28, 1:40:17 PMbr--brbThis Is Our Emergency/bbrby ibPretty Girls Make Graves/bibriThe New Romance/ibrPlayed: 2004/07/28, 1:36:37 PMbr--brbFreestylin'/bbrby ibGreyboy/bibriFreestylin'/ibrPlayed: 2004/07/28, 1:30:25 PMbr--brbIn My Head/bbrby ibNaked Raygun/bibriRaygun...Naked Raygun (Reissue)/ibrPlayed: 2004/07/28, 1:26:37 PMbr--brbLust To Love/bbrby ibThe Go-Go's/bibriReturn To The Valley Of The Go-Go's/ibrPlayed: 2004/07/28, 1:23:13 PMbr--brbKim You Bore Me To Death/bbrby ibGrandaddy/bibriConcrete Dunes/ibrPlayed: 2004/07/28, 1:18:37 PMbr--brbSonderkommando/bbrby ibGwar/bibriThis Toilet Earth/ibrPlayed: 2004/07/28, 1:13:49 PMbr--br Now what I want to do is read this file, but only say read 5 songs worth, then I would place the PHP code in (another table) and display the next 5 songs and so on This just allows for a more flexible layout in the final presentation. the way I am having the text files written, there is no way to get it to produce seperate text files - otherwise this would be easy to do Is this possible? Thanks in advance! Dustin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] reading txt file - certain lines
Dustin Krysak wrote: Hi there.. .I am displaying info (on music) from a text file with the following code... ?php //open the file handler $fp02=fopen(assets/lib/php/itunes/recent.txt,r); //Read the track info $recent=fgets($fp02); //close the file. echo $recent; fclose($fp02); ? Now the contents of said text file would read something like the following: bLiar/bbrby ibSex Pistols/bibriNever Mind The Bollocks/ibrPlayed: 2004/07/28, 1:48:29 PMbr--brbLet's Rave On/bbrby ibThe Raveonettes/bibriChain Gang Of Love/ibrPlayed: 2004/07/28, 1:46:37 PMbr--brbNo Remorse/bbrby ibMetallica/bibriKill 'Em All/ibrPlayed: 2004/07/28, 1:40:17 PMbr--brbThis Is Our Emergency/bbrby ibPretty Girls Make Graves/bibriThe New Romance/ibrPlayed: 2004/07/28, 1:36:37 PMbr--brbFreestylin'/bbrby ibGreyboy/bibriFreestylin'/ibrPlayed: 2004/07/28, 1:30:25 PMbr--brbIn My Head/bbrby ibNaked Raygun/bibriRaygun...Naked Raygun (Reissue)/ibrPlayed: 2004/07/28, 1:26:37 PMbr--brbLust To Love/bbrby ibThe Go-Go's/bibriReturn To The Valley Of The Go-Go's/ibrPlayed: 2004/07/28, 1:23:13 PMbr--brbKim You Bore Me To Death/bbrby ibGrandaddy/bibriConcrete Dunes/ibrPlayed: 2004/07/28, 1:18:37 PMbr--brbSonderkommando/bbrby ibGwar/bibriThis Toilet Earth/ibrPlayed: 2004/07/28, 1:13:49 PMbr--br Now what I want to do is read this file, but only say read 5 songs worth, then I would place the PHP code in (another table) and display the next 5 songs and so on This just allows for a more flexible layout in the final presentation. the way I am having the text files written, there is no way to get it to produce seperate text files - otherwise this would be easy to do Is this possible? Yes, possible. Worth the time? No. Can you put all that info in a database? -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] reading txt file - certain lines
Yeah I do not really have the option to use a database here since the way the data is output is limited to a text file.. the files are populated by a program that takes the currently playing tracks out of Itunes (mp3 player) on my mac. d On 28-Jul-04, at 3:26 PM, [EMAIL PROTECTED] wrote: From: John Nichel [EMAIL PROTECTED] Date: July 28, 2004 2:05:51 PM PDT To: PHP [EMAIL PROTECTED] Subject: Re: [PHP] reading txt file - certain lines Dustin Krysak wrote: Hi there.. .I am displaying info (on music) from a text file with the following code... ?php //open the file handler $fp02=fopen(assets/lib/php/itunes/recent.txt,r); //Read the track info $recent=fgets($fp02); //close the file. echo $recent; fclose($fp02); ? Now the contents of said text file would read something like the following: bLiar/bbrby ibSex Pistols/bibriNever Mind The Bollocks/ibrPlayed: 2004/07/28, 1:48:29 PMbr--brbLet's Rave On/bbrby ibThe Raveonettes/bibriChain Gang Of Love/ibrPlayed: 2004/07/28, 1:46:37 PMbr--brbNo Remorse/bbrby ibMetallica/bibriKill 'Em All/ibrPlayed: 2004/07/28, 1:40:17 PMbr--brbThis Is Our Emergency/bbrby ibPretty Girls Make Graves/bibriThe New Romance/ibrPlayed: 2004/07/28, 1:36:37 PMbr--brbFreestylin'/bbrby ibGreyboy/bibriFreestylin'/ibrPlayed: 2004/07/28, 1:30:25 PMbr--brbIn My Head/bbrby ibNaked Raygun/bibriRaygun...Naked Raygun (Reissue)/ibrPlayed: 2004/07/28, 1:26:37 PMbr--brbLust To Love/bbrby ibThe Go-Go's/bibriReturn To The Valley Of The Go-Go's/ibrPlayed: 2004/07/28, 1:23:13 PMbr--brbKim You Bore Me To Death/bbrby ibGrandaddy/bibriConcrete Dunes/ibrPlayed: 2004/07/28, 1:18:37 PMbr--brbSonderkommando/bbrby ibGwar/bibriThis Toilet Earth/ibrPlayed: 2004/07/28, 1:13:49 PMbr--br Now what I want to do is read this file, but only say read 5 songs worth, then I would place the PHP code in (another table) and display the next 5 songs and so on This just allows for a more flexible layout in the final presentation. the way I am having the text files written, there is no way to get it to produce seperate text files - otherwise this would be easy to do Is this possible? Yes, possible. Worth the time? No. Can you put all that info in a database? -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED]
[PHP] reading/parsing file names
my problem: I've got a list of files in a directory, and I'd like to get a only of filenames that end in .jpg, however, exlude the files that end in .thumb.jpg ex: file.php index.htm photo.jpg photo.thumb.jpg etc how can I count only those files that end with .jpg ? Any help appreciated. -- koly out. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] reading/parsing file names
php.net/substr php.net/ereg php.net/preg_match foreach ( $files as $filename ) if ( substr($filename, -4) == '.jpg' ) array_push($jpegs, $filename); Keep in mind, though, that not all JPEG files end with jpg. There is also jpe and jpeg, and you have to consider case sensitivity. On Saturday 25 October 2003 03:41 pm, koly wrote: my problem: I've got a list of files in a directory, and I'd like to get a only of filenames that end in .jpg, however, exlude the files that end in .thumb.jpg ex: file.php index.htm photo.jpg photo.thumb.jpg etc how can I count only those files that end with .jpg ? Any help appreciated. -- Evan Nemerson [EMAIL PROTECTED] -- I am indeed amazed when I consider how weak my mind is and how prone to error. -Rene Descartes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reading a file from another server
I know the url is good, cause I can go on to this domain and look at all my files. I guess I should explain a little further... This server is a game server for Counter-Strike. I'm trying to read a file on there called mapcycle.txt. This server is a secure server, so I would need to use a username and password to get on. I I've tried a bunch of different things, and now I find that it has a problem connecting to secure servers. DO you know of a different way to connect to a secure server anhd get information other than the way I have been trying? This is what I'm usuing right now: ?php $prefix = ftp://;; $username = myUsername; $password = **; $url = server.username.gameserver.com/; $filename = test.txt; $result = readfile($prefix . $username . : . $password . @ . $url . $filename); print ($result); ? // OUTPUT 0 if I use anythign other than the ftp:// for a prefix (like http. or https) I get an error. Cheers. Chris Shiflett [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] --- Thomas [EMAIL PROTECTED] wrote: readfile(ftp://username:[EMAIL PROTECTED]/test.txt); It doesn't have any errors and comes up blank. If I put: $result = readfile(ftp://username:[EMAIL PROTECTED]/test.txt); print ($result); it ends up showing a '0' by iteself. The readfile() functions outputs the contents of the file and returns the size of the file in bytes. So, when you assigned $result to the return value, you demonstrated that readfile() output 0 bytes (which explains why you didn't see anything). I'm pretty sure your php.ini is set to allow this, otherwise you would receive an error. I'm doubting whether that URL actually contains any content. How have you tested to be sure it does? Chris = Become a better Web developer with the HTTP Developer's Handbook http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reading a file from another server
Have you tried downloading the file to your server and then read it from there? I do this at least 15 times a day with several different sites and I rarely have any problems. CDitty At 11:28 AM 7/26/2003, Thomas wrote: I know the url is good, cause I can go on to this domain and look at all my files. I guess I should explain a little further... This server is a game server for Counter-Strike. I'm trying to read a file on there called mapcycle.txt. This server is a secure server, so I would need to use a username and password to get on. I I've tried a bunch of different things, and now I find that it has a problem connecting to secure servers. DO you know of a different way to connect to a secure server anhd get information other than the way I have been trying? This is what I'm usuing right now: ?php $prefix = ftp://;; $username = myUsername; $password = **; $url = server.username.gameserver.com/; $filename = test.txt; $result = readfile($prefix . $username . : . $password . @ . $url . $filename); print ($result); ? // OUTPUT 0 if I use anythign other than the ftp:// for a prefix (like http. or https) I get an error. Cheers. Chris Shiflett [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] --- Thomas [EMAIL PROTECTED] wrote: readfile(ftp://username:[EMAIL PROTECTED]/test.txt); It doesn't have any errors and comes up blank. If I put: $result = readfile(ftp://username:[EMAIL PROTECTED]/test.txt); print ($result); it ends up showing a '0' by iteself. The readfile() functions outputs the contents of the file and returns the size of the file in bytes. So, when you assigned $result to the return value, you demonstrated that readfile() output 0 bytes (which explains why you didn't see anything). I'm pretty sure your php.ini is set to allow this, otherwise you would receive an error. I'm doubting whether that URL actually contains any content. How have you tested to be sure it does? Chris = Become a better Web developer with the HTTP Developer's Handbook http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reading a file from another server
* Thus wrote Thomas ([EMAIL PROTECTED]): I know the url is good, cause I can go on to this domain and look at all my files. I guess I should explain a little further... This server is a game server for Counter-Strike. I'm trying to read a file on there called mapcycle.txt. This server is a secure server, so I would need to use a username and password to get on. I I've tried a bunch of different things, and now I find that it has a problem connecting to secure servers. DO you know of a different way to connect to a secure server anhd get information other than the way I have been trying? I wouldn't use the term 'secure', rather password protected. A plain text username and password is far from being secure. This is what I'm usuing right now: ?php $prefix = ftp://;; $username = myUsername; $password = **; $url = server.username.gameserver.com/; $filename = test.txt; $result = readfile($prefix . $username . : . $password . @ . $url . $filename); print ($result); ? // OUTPUT 0 This can be expected output pending a few settings from a phpinfo result: error_reporting: safe_mode: allow_url_fopen: if I use anythign other than the ftp:// for a prefix (like http. or https) I get an error. what are the errors? Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Reading a file from another server
Hi Everyone. I'm having problems creating code to read a file from another server. 1. Is this even possible? with a secure server aswell? 2. I have tried using fopen()but this always gives me an error: Warning: stat failed for http://www.domain.com/test.txt (errno=2 - No such file or directory) in /home/domain/public_html/php/testphp/test.php on line 4 this is my code: ?php $filename = http://www.domain.com/test.txt;; $handle = fopen ($filename, r); $content = fread($handle, filesize ($filename)); fclose($handle); echo $content; ? can anyone help me. I need to put this on my server, and read this other file form a game serverbut I can't seem to do it. Cheers for any help -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reading a file from another server
--- Thomas [EMAIL PROTECTED] wrote: I'm having problems creating code to read a file from another server. 1. Is this even possible? with a secure server aswell? Yes. this is my code: ?php $filename = http://www.domain.com/test.txt;; $handle = fopen ($filename, r); $content = fread($handle, filesize ($filename)); fclose($handle); echo $content; ? This code can be replaced with: readfile('http://www.domain.com/test.txt'); As far as debugging problems related to this, check your php.ini and make sure the URL wrapper is enabled. Otherwise, you will be restricted to your local filesystem only. Hope that helps. Chris = Become a better Web developer with the HTTP Developer's Handbook http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reading a file from another server
if I use: readfile(ftp://username:[EMAIL PROTECTED]/test.txt); It doesn't have any errors and comes up blank. If I put: $result = readfile(ftp://username:[EMAIL PROTECTED]/test.txt); print ($result); it ends up showing a '0' by iteself. that's it. and I knwo the txt file is full of info. I'm stumped again. Cheers. for your help. Thomas Chris Shiflett [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] --- Thomas [EMAIL PROTECTED] wrote: I'm having problems creating code to read a file from another server. 1. Is this even possible? with a secure server aswell? Yes. this is my code: ?php $filename = http://www.domain.com/test.txt;; $handle = fopen ($filename, r); $content = fread($handle, filesize ($filename)); fclose($handle); echo $content; ? This code can be replaced with: readfile('http://www.domain.com/test.txt'); As far as debugging problems related to this, check your php.ini and make sure the URL wrapper is enabled. Otherwise, you will be restricted to your local filesystem only. Hope that helps. Chris = Become a better Web developer with the HTTP Developer's Handbook http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reading a file from another server
--- Thomas [EMAIL PROTECTED] wrote: readfile(ftp://username:[EMAIL PROTECTED]/test.txt); It doesn't have any errors and comes up blank. If I put: $result = readfile(ftp://username:[EMAIL PROTECTED]/test.txt); print ($result); it ends up showing a '0' by iteself. The readfile() functions outputs the contents of the file and returns the size of the file in bytes. So, when you assigned $result to the return value, you demonstrated that readfile() output 0 bytes (which explains why you didn't see anything). I'm pretty sure your php.ini is set to allow this, otherwise you would receive an error. I'm doubting whether that URL actually contains any content. How have you tested to be sure it does? Chris = Become a better Web developer with the HTTP Developer's Handbook http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] reading a file into variable for using in a javascript
Hi all, I am reading the content of a text file into a variable to be used in a javascript. I am reworking some code that was originally done using ColdFusion and the jsStringFormat(var) function. What is the PHP equivalent string function? Is there one? I have searched the docs, but can't figure out which to use. Thanks Charles -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Reading from file on local disk to server
Hi everyone This is what I want to do: I have a file on each workstation that gets created each time the pc is rebooted - the file save the pc configuration plus the current user logged onto the machine, I want to read from that file variables so that I can save it to my mySQL database and run queries on the data. - I have no problem reading from a file if it is on the web server, but am experiencing problems reading from the file on the remote client pc. - any suggestions? This is what I can do: Read from file on web server, set it to variables and write it to a mySQL database. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Reading Text file by line
I need to read a text file by line, if I open the file and use fgets() then it doesn't pick up the EOL corretly. So I was planning on reading the whole file in with fread() and then breaking it up by EOL characters. My question is, how do I do it? What character do I search for in the string? Anyone have a simple example on how to do this? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Reading Text file by line
Using $var=file('filename.txt'); Creates an array, with each element in the array being 1 line of the file. Thanks Mark -Original Message- From: Anthony [mailto:[EMAIL PROTECTED] Sent: 24 February 2003 16:24 To: [EMAIL PROTECTED] Subject: [PHP] Reading Text file by line I need to read a text file by line, if I open the file and use fgets() then it doesn't pick up the EOL corretly. So I was planning on reading the whole file in with fread() and then breaking it up by EOL characters. My question is, how do I do it? What character do I search for in the string? Anyone have a simple example on how to do this? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reading Text file by line
At 17:24 24.02.2003, Anthony spoke out and said: [snip] I need to read a text file by line, if I open the file and use fgets() then it doesn't pick up the EOL corretly. So I was planning on reading the whole file in with fread() and then breaking it up by EOL characters. My question is, how do I do it? What character do I search for in the string? Anyone have a simple example on how to do this? Thanks. [snip] A line is usually terminated by either LF (Unix-Style) or CRLF (Win style). I heard that some macies do it the other way round, terminating with either only CR ot LFCR. If you don't know exactly how lines will be terminated, first use str_replace to normalize the line terminations: $data = str_replace(array(\r\n, \n\r, \r, \n), \n, $data); then simple explode() the data to receive an array of lines: $arlines = explode(\n, $data); You could also use preg_split to combine these operations: $arlines = preg_split(/(\r\n|\n\r|\r|\n)/s, $data); Disclaimer: all untested. -- O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Reading Session File from /tmp directory
I am trying to read a session file from the /tmp directory then restore the PHP variables from this but I can't get it to work, i'm doing the following: $acontents = file(/tmp/sess_$sessid); $data = $acontents[0]; unserialize($data); $sessid is a valid session id, but unserialize doesn't give me the values for $hostname, $username, etc? Any help? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] reading excel file
Hi , I converted .CSV (comma delimited) file to MySQL it 's easy to use it... Tyler Longren To: php-general [EMAIL PROTECTED] tyler@captaicc: (bcc: EMIN CALIKLI/FINANSBANK) njack.com Subject: [PHP] reading excel file 03.04.2002 04:30 Hello List, Has anyone ever converted an excel file over to a MySQL database via PHP? I'm currently doing it with perl, and this isn't a very good option for me. The client needs to login to a server via ssh every time they want to put data from their excel file to mysql. I'd like to find some way to do it through a web browser. Thanks for any suggestions, Tyler Longren Captain Jack Communications [EMAIL PROTECTED] www.captainjack.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] reading excel file
Hello List, Has anyone ever converted an excel file over to a MySQL database via PHP? I'm currently doing it with perl, and this isn't a very good option for me. The client needs to login to a server via ssh every time they want to put data from their excel file to mysql. I'd like to find some way to do it through a web browser. Thanks for any suggestions, Tyler Longren Captain Jack Communications [EMAIL PROTECTED] www.captainjack.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] reading excel file
Has anyone ever converted an excel file over to a MySQL database via PHP? I'm currently doing it with perl, and this isn't a very good option for me. The client needs to login to a server via ssh every time they want to put data from their excel file to mysql. I'd like to find some way to do it through a web browser. If you can get them to save the Excel file as tab-delimited, you could just read it, explode on \t and assemble your SQL insert statements. Failing that, you could continue to use the Perl script but accept the Excel file as a HTTP upload, and have PHP run the Perl script. J -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] reading excel file
Thanks Jason, that is a pretty good idea. Any idea how well PHP handles large ammounts of data like that? There'll be about 25,000 lines in every excel file, and they come in groups of 5 or 6. Tyler Longren Captain Jack Communications [EMAIL PROTECTED] www.captainjack.com - Original Message - From: Jason Murray [EMAIL PROTECTED] To: 'Tyler Longren' [EMAIL PROTECTED]; php-general [EMAIL PROTECTED] Sent: Tuesday, April 02, 2002 7:32 PM Subject: RE: [PHP] reading excel file Has anyone ever converted an excel file over to a MySQL database via PHP? I'm currently doing it with perl, and this isn't a very good option for me. The client needs to login to a server via ssh every time they want to put data from their excel file to mysql. I'd like to find some way to do it through a web browser. If you can get them to save the Excel file as tab-delimited, you could just read it, explode on \t and assemble your SQL insert statements. Failing that, you could continue to use the Perl script but accept the Excel file as a HTTP upload, and have PHP run the Perl script. J -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] reading excel file
If it's possible, it probably better to deal with each line by itself, rather than try to load to whole file into memory. Martin -Original Message- From: Tyler Longren [mailto:[EMAIL PROTECTED]] Sent: Wednesday, April 03, 2002 11:37 AM To: Jason Murray; php-general Subject: Re: [PHP] reading excel file Thanks Jason, that is a pretty good idea. Any idea how well PHP handles large ammounts of data like that? There'll be about 25,000 lines in every excel file, and they come in groups of 5 or 6. Tyler Longren Captain Jack Communications [EMAIL PROTECTED] www.captainjack.com - Original Message - From: Jason Murray [EMAIL PROTECTED] To: 'Tyler Longren' [EMAIL PROTECTED]; php-general [EMAIL PROTECTED] Sent: Tuesday, April 02, 2002 7:32 PM Subject: RE: [PHP] reading excel file Has anyone ever converted an excel file over to a MySQL database via PHP? I'm currently doing it with perl, and this isn't a very good option for me. The client needs to login to a server via ssh every time they want to put data from their excel file to mysql. I'd like to find some way to do it through a web browser. If you can get them to save the Excel file as tab-delimited, you could just read it, explode on \t and assemble your SQL insert statements. Failing that, you could continue to use the Perl script but accept the Excel file as a HTTP upload, and have PHP run the Perl script. J -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] reading excel file
Thanks Jason, that is a pretty good idea. Any idea how well PHP handles large ammounts of data like that? There'll be about 25,000 lines in every excel file, and they come in groups of 5 or 6. I've rigged up an import script for similar functions before, it seems to run ok... it really depends on the specs of the server you're running it on. If you notice slowness, consider raising the timeout by X seconds per Y lines, then you can judge the size of the incoming file and change how long PHP gets to run. J -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] reading excel file
If it's possible, it probably better to deal with each line by itself, rather than try to load to whole file into memory. Good point. Shared server admins probably hate me. ;) J -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] reading excel file
If you are running your server on windows, you may also have the option of using COM to access Excel to open the file and read the information contained in each cell, See http://www.php.net/manual/en/ref.com.php Warren Vail Tools, Metrics Quality Processes (415) 667-7814 Pager (877) 774-9891 215 Fremont 02-658 -Original Message- From: Jason Murray [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 02, 2002 5:33 PM To: 'Tyler Longren'; php-general Subject: RE: [PHP] reading excel file Has anyone ever converted an excel file over to a MySQL database via PHP? I'm currently doing it with perl, and this isn't a very good option for me. The client needs to login to a server via ssh every time they want to put data from their excel file to mysql. I'd like to find some way to do it through a web browser. If you can get them to save the Excel file as tab-delimited, you could just read it, explode on \t and assemble your SQL insert statements. Failing that, you could continue to use the Perl script but accept the Excel file as a HTTP upload, and have PHP run the Perl script. J -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Reading A file
Hey I have a TEXT file that I want to make visual via the web using php
RE: [PHP] Reading A file
I have a TEXT file that I want to make visual via the web using php ?php include (my_text_file.txt); ? HTH Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reading A file
Hey I have a TEXT file that I want to make visual via the web using php Maybe this isn't the best way but to do this I use the following code: ?php function do_print($item2,$clave) { echo $item2.BR; } $lines=file(yourfile.txt); array_walk($lines,'do_print'); ? As you can see I use the file() function to get each line of text into an array and then the function array_walk() to do the visualization. Hope it helps! Fernando -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Reading A file
Ok I have a file like this and a want to isert this into a mysql table It has to be field Date data Mar 06 15:45:24 field bksvr buops field Message NetWorker Savegroup: (alert) Manutan aborted, 2 client(s) (manutan-pre01, manutan-omct Failed) Log file Mar 06 15:45:24 buops: NetWorker Savegroup: (alert) Manutan aborted, 2 client(s) (manutan-pre01, manutan-omct Failed) Mar 06 15:45:24 buops: Start time: Wed Mar 06 15:42:01 2002 Mar 06 15:45:24 buops: End time: Wed Mar 06 15:45:24 2002 Mar 06 15:45:24 buops: --- Never Started Save Sets --- Mar 06 15:45:24 buops: savegrp: manutan-pre01:index index was never started -Original Message- From: Ing. Fernando Proll Segura [mailto:[EMAIL PROTECTED]] Sent: mercredi 6 mars 2002 15:13 To: Sven Jacobs; [EMAIL PROTECTED] Subject: Re: [PHP] Reading A file Hey I have a TEXT file that I want to make visual via the web using php Maybe this isn't the best way but to do this I use the following code: ?php function do_print($item2,$clave) { echo $item2.BR; } $lines=file(yourfile.txt); array_walk($lines,'do_print'); ? As you can see I use the file() function to get each line of text into an array and then the function array_walk() to do the visualization. Hope it helps! Fernando
RE: [PHP] Reading A file and placing data into db
Ok I have a file like this and a want to isert this into a mysql table It has to be field Date data Mar 06 15:45:24 field bksvr buops field Message NetWorker Savegroup: (alert) Manutan aborted, 2 client(s) (manutan-pre01, manutan-omct Failed) Log file Mar 06 15:45:24 buops: NetWorker Savegroup: (alert) Manutan aborted, 2 client(s) (manutan-pre01, manutan-omct Failed) Mar 06 15:45:24 buops: Start time: Wed Mar 06 15:42:01 2002 Mar 06 15:45:24 buops: End time: Wed Mar 06 15:45:24 2002 Mar 06 15:45:24 buops: --- Never Started Save Sets --- Mar 06 15:45:24 buops: savegrp: manutan-pre01:index index was never started -Original Message- From: Ing. Fernando Proll Segura [mailto:[EMAIL PROTECTED]] Sent: mercredi 6 mars 2002 15:13 To: Sven Jacobs; [EMAIL PROTECTED] Subject: Re: [PHP] Reading A file Hey I have a TEXT file that I want to make visual via the web using php Maybe this isn't the best way but to do this I use the following code: ?php function do_print($item2,$clave) { echo $item2.BR; } $lines=file(yourfile.txt); array_walk($lines,'do_print'); ? As you can see I use the file() function to get each line of text into an array and then the function array_walk() to do the visualization. Hope it helps! Fernando
[PHP] reading a file into a string problem : $string = join ('', file (/location/$dynamic.iq))
Hi, I wonder if someone can help me solve this niggling problem: I have a hyperlink [javascript:openwindow('http:myserver/files.php?expid=67.iq')], which passes the argument 'expid' to the PHP script, where 'expid' is the name of a file. I want to take the file data and put it into a string. When I do so by naming the file in the script it works fine e.g. $fcontents = join ('', file ('myserbver/files/67.iq')); But when I do $fcontents = join ('', file ('myserver/files/$expid')); // where $expid = 67.iq I get the following errors --- Warning: file(myserver/files/$expid) - No error in c:\program files\apache group\apache\htdocs\sasdap\v5\files.php on line 4 Warning: Bad arguments to join() in c:\program files\apache group\apache\htdocs\sasdap\v5\files.php on line 4 --- I've also tried $file_location=myserver/files/$expid; $fcontents = join ('', file ('$file_location')); I'm new to PHP and am so far only working with the online documentation. Can anyone help and/or explain the problem? Thanks in advance ;-) - Best regards, Lee -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] reading from file
I am using the script include below to read the content of a file and output it. When I load this script with the adress of a plain html file it outputs everything like expected, except there are some extra characters spread over the file. They come in little string like '40d' or '1000' and appear on positions where there is 'nothing' in the original source file. Any idea what could cause that behavior? Stefan ? $myServer = 'xxx.xxx.xxx.xx'; $document = 'index.shtml'; $fp=fsockopen($myServer,80,$errno,$errstr,30); $request = GET $document HTTP/1.1\r\nAuthorization: Basic ; $request .= base64_encode(xx:xx) . \r\n; $request .= Host: $myServer\r\n\r\n; if(!$fp) { echo $errstr ($errno)br\n; } else { fputs($fp,$request); while(!feof($fp)) { $line=fgets($fp,4096); echo $line; } fclose($fp); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Reading a file and changing a href tag values
All you need is a regular expression, provided by ereg function or preg functions. You'd have the regex look for a href then capture everything up to /a Then just adjust the result as you want it to appear. You'll need to either search around for code that already does this, or be willing to learn regular expressions (which you should do anyway). Otherwise it will seem impossible. -- Plutarck Should be working on something... ...but forgot what it was. ""Brett"" [EMAIL PROTECTED] wrote in message 012701c0c4a2$cbc7f840$LocalHost@Default">news:012701c0c4a2$cbc7f840$LocalHost@Default... I have been able to find out how to read a file and replace certain matches, but I want to be able to take a web page stored in a string and change the a href tags and add www.mysite.com?page= before the actual link value so the new url would read www.mysite.com?page=original_url. Can I do this and if so will someone give me an idea how? Thanks. Brett -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Reading a file and changing a href tag values
I have been able to find out how to read a file and replace certain matches, but I want to be able to take a web page stored in a string and change the a href tags and add www.mysite.com?page= before the actual link value so the new url would read www.mysite.com?page=original_url. Can I do this and if so will someone give me an idea how? Thanks. Brett -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]