RE: [PHP-DB] Using text files instead of a DB
ah ... apologies i was confused by the 'i want to pay by check' on an otherwise blank page. following the link does indeed give the offers you suggested. shame i'm in the uk ... once again, apologies abound. Steve -Original Message- From: Rick Emery [mailto:[EMAIL PROTECTED]] Sent: 13 March 2001 18:57 To: Steve Brett; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Using text files instead of a DB Sir, you did NOT follow the link I mentioned: http://intercession.net/specialoffers. This offers the web-hosting at %59.40 for the year. Instead you followed the link on http://intercession.net. -Original Message- From: Steve Brett [mailto:[EMAIL PROTECTED]] Sent: Tuesday, March 13, 2001 10:53 AM To: Rick Emery; '[EMAIL PROTECTED]'; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Using text files instead of a DB so ... Virtual Web Site Hosting* 250 MB - $199.99/year one time setup fee. if i divide 199 by 12 i get 5 -Original Message- From: Rick Emery [mailto:[EMAIL PROTECTED]] Sent: 13 March 2001 14:39 To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Using text files instead of a DB I use an ISP (http://intercession.net/specialoffers) who provides PHP and MySQL support on an Apache server (Cobalt Linux) for $5 per month...yes, $5 per month. No extra charges for either. $250 meg space. Full FTP. -Original Message- From: David W. Fenton [mailto:[EMAIL PROTECTED]] Sent: Monday, March 12, 2001 8:41 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Using text files instead of a DB On 12 Mar 01, at 15:30, Phillip Bow wrote: It is absolutely possible though for anything big I would spring for the db access. PHP shares a lot of the functionality that makes Perl a good tool for this type of job so either language is a good choice. For PHP you will want to check out the f-functions(fopen, fread, fwrite), and some of the string manipulation functions(implode, explode, and ereg/preg). Your best bet may be to grab a book that covers string manipulation, and file handling(Wrox Professional PHP programming does I know) to use as reference. So, there's nothing on the web that demonstrates text-file manipulation? OK. I was hoping for an example somewhere that I could dig into and learn from, but if I have to buy a book, well, I'm still trying to figure out if PHP is what I want to use or not. I'm much more comfortable with Cold Fusion, though no more experienced. CF is much more compatible with what I already know and I got the same results with CF in about 1/3 the time it took me in PHP. Unfortunately, CF would require a change of ISP, and I really don't want to change ISPs (that would be a horrible thing, having been with the same ISP since the beginning of 1996). I don't think I want to spend money on a book for a platform that I may discard. Maybe I can negotiate with the ISP (I've done it before in behalf of clients). -- David W. Fenton | http://www.bway.net/~dfenton David Fenton Associates | http://www.bway.net/~dfassoc -- PHP Database 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 Database 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 Database 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-DB] Using text files instead of a DB
Does your ISP have XML and Sabloton support installed for PHP? If so it would be worth considering an XML solution. Alan Hale "David W. Fenton" wrote: I'm very new to PHP, and don't know where to look to answer this question. Is it possible to use a collection of delimited text files with PHP instead of a database engine? I'm trying to save $50/month, which is what MySQL support costs from my ISP (can't move ISPs). The application is a simple form-driven search function, having three multi-select listboxes that would be populated from three text files as criteria to pull records from a single text file. Would such a setup require PERL or the like? And, if so, would it be better to build the whole thing in PERL (which I don't know, either)? Any pointers to information on the subject gratefully received. -- David W. Fenton |http://www.bway.net/~dfenton David Fenton Associates |http://www.bway.net/~dfassoc -- PHP Database 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 Database 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-DB] Using text files instead of a DB
This following script might help. It assumes you are reading in a file with the following format: 0;this is line zero 1;this is a line one 2;this is a line two 3;this is a line three 4;this is a line four 5;this is a line five ?php // get a the file into an array, you wouldn't want to do this for a very big file // I tried it with a file 4000+ lines and it seemed to work just fine // if you know the file will be big then we would read only a limited number of lines // at a time using fopen() and fgets() $fcontents = file ('products.txt'); // I provide the following variable ($method) in the url // For example: // http://www.yoursite.com/index.phtml?method=idproduct_id=123 if($method == "id"){ // Loop through the file trying to match the begining // of a line with the desired id while (list ($line_num, $line) = each ($fcontents)) { if(ereg("^".$keyword, $line)){ echo "bLine $line_num:/b " . htmlspecialchars ($line) . "br\n"; } } // keywords are seperated by | (pipe) // For example: // http://www.yoursite.com/index.phtml?method=searchkeyword=black|piano|mozart }elseif($method == "search"){ while (list ($line_num, $line) = each ($fcontents)) { // Notice the use of eregi() for the keyword part // it allows for case-insensitive searches if(eregi($keyword, $line)){ echo "bLine $line_num:/b " . htmlspecialchars ($line) . "br\n"; } } }else{ // supply a method, or do not run } ? Robert Zwink -Original Message- From: David W. Fenton [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 14, 2001 12:02 AM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] Using text files instead of a DB On 13 Mar 01, at 9:43, Robert V. Zwink wrote: http://phpclasses.upperdesign.com/browse.html/package/52 Thanks for this. Very simple and straightforward, but I don't see much in there that helps me. The above link will take you to a class to manipulate CSV files. This might help you understand file access in php. If you want to maintain a database within a text file using CSV file format may help. There is not (and will never be) any editing of this text file on the website. It's simply read-only, a periodically uploaded catalog of selected items to allow website viewers to search selected inventory on this client's website: http://www.wurlitzerbruck.com/. If you have specific questions don't hesitate to post. [Keep in mind that I'm an experienced Visual Basic programmer but I've never done very much file I/O and I'm a complete newbie to PHP with no PERL experience, either] I can open the file with fgetcsv(), and there it all is in an array, which is very nice. However, what I really want is to pull only rows matching certain criteria into an array and then display *those*. I've created the data output as a flat file, with the many-to-one data flattened into single fields. [am I correct in surmising that the array created by fgetcsv() is addressable only by index number, and not by column name?] I need to match on: CreatorID (one per row, exact match) CreatorCategories (multiple items per row, match multiple partial strings) KeyWords (multiple items per row, match partial string) Title (one per row, partial match against a concatenation of three columns) The WHERE clause from my ODBC SQL strings would run like this: WHERE (CreatorID IN (232,654,1034)) AND (CreatorCategories Like '%Composer%' OR CreatorCategories Like '%Pianist%') AND (KeyWords Like '%Ballet%' OR KeyWords Like '%Cantatas%' OR KeyWords Like '%Chamber Music%') AND ((BibHeader AutoHeader OtherHeader) Like 'Sonata%') (the example makes no sense, of course, but includes all the possibilities). Now, obviously, I need a regular expression to compare a field value to a list of values, and another to see if any of a list of values is a substring of the field value. Regular expressions always make my eyes glaze over, but these are so simple (aren't they?) that I can't see any examples that I can understand are applicable to what I want -- the examples all seem designed to help you with more complicated tasks than what I need. And, obviously, I want to return just the rows that have a match. If I have the whole file in an array (with fgetcsv()), the row number of the array should be all I need to return, and then I can copy that whole row into a second array. What I'd really like is a way that would selectively copy to an array rather than copying from one big array to a smaller array, but the file has to be open, in memory, either way, right? Or can one read it in one line at a time, test against the conditions, and copy to the array or move on depending on the match?
RE: [PHP-DB] Using text files instead of a DB
CORRECTION: (removed $ from in front of 250 meg) I use an ISP (http://intercession.net/specialoffers) who provides PHP and MySQL support on an Apache server (Cobalt Linux) for $5 per month...yes, $5 per month. No extra charges for either. 250 meg space. Full FTP. -Original Message- From: Rick Emery [mailto:[EMAIL PROTECTED]] Sent: Tuesday, March 13, 2001 8:39 AM To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Using text files instead of a DB I use an ISP (http://intercession.net/specialoffers) who provides PHP and MySQL support on an Apache server (Cobalt Linux) for $5 per month...yes, $5 per month. No extra charges for either. $250 meg space. Full FTP. -Original Message- From: David W. Fenton [mailto:[EMAIL PROTECTED]] Sent: Monday, March 12, 2001 8:41 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Using text files instead of a DB On 12 Mar 01, at 15:30, Phillip Bow wrote: It is absolutely possible though for anything big I would spring for the db access. PHP shares a lot of the functionality that makes Perl a good tool for this type of job so either language is a good choice. For PHP you will want to check out the f-functions(fopen, fread, fwrite), and some of the string manipulation functions(implode, explode, and ereg/preg). Your best bet may be to grab a book that covers string manipulation, and file handling(Wrox Professional PHP programming does I know) to use as reference. So, there's nothing on the web that demonstrates text-file manipulation? OK. I was hoping for an example somewhere that I could dig into and learn from, but if I have to buy a book, well, I'm still trying to figure out if PHP is what I want to use or not. I'm much more comfortable with Cold Fusion, though no more experienced. CF is much more compatible with what I already know and I got the same results with CF in about 1/3 the time it took me in PHP. Unfortunately, CF would require a change of ISP, and I really don't want to change ISPs (that would be a horrible thing, having been with the same ISP since the beginning of 1996). I don't think I want to spend money on a book for a platform that I may discard. Maybe I can negotiate with the ISP (I've done it before in behalf of clients). -- David W. Fenton | http://www.bway.net/~dfenton David Fenton Associates | http://www.bway.net/~dfassoc -- PHP Database 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 Database 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 Database 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-DB] Using text files instead of a DB
http://phpclasses.upperdesign.com/browse.html/package/52 The above link will take you to a class to manipulate CSV files. This might help you understand file access in php. If you want to maintain a database within a text file using CSV file format may help. If you have specific questions don't hesitate to post. Robert Zwink -Original Message- From: Rick Emery [mailto:[EMAIL PROTECTED]] Sent: Tuesday, March 13, 2001 9:42 AM To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Using text files instead of a DB CORRECTION: (removed $ from in front of 250 meg) I use an ISP (http://intercession.net/specialoffers) who provides PHP and MySQL support on an Apache server (Cobalt Linux) for $5 per month...yes, $5 per month. No extra charges for either. 250 meg space. Full FTP. -Original Message- From: Rick Emery [mailto:[EMAIL PROTECTED]] Sent: Tuesday, March 13, 2001 8:39 AM To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Using text files instead of a DB I use an ISP (http://intercession.net/specialoffers) who provides PHP and MySQL support on an Apache server (Cobalt Linux) for $5 per month...yes, $5 per month. No extra charges for either. $250 meg space. Full FTP. -Original Message- From: David W. Fenton [mailto:[EMAIL PROTECTED]] Sent: Monday, March 12, 2001 8:41 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Using text files instead of a DB On 12 Mar 01, at 15:30, Phillip Bow wrote: It is absolutely possible though for anything big I would spring for the db access. PHP shares a lot of the functionality that makes Perl a good tool for this type of job so either language is a good choice. For PHP you will want to check out the f-functions(fopen, fread, fwrite), and some of the string manipulation functions(implode, explode, and ereg/preg). Your best bet may be to grab a book that covers string manipulation, and file handling(Wrox Professional PHP programming does I know) to use as reference. So, there's nothing on the web that demonstrates text-file manipulation? OK. I was hoping for an example somewhere that I could dig into and learn from, but if I have to buy a book, well, I'm still trying to figure out if PHP is what I want to use or not. I'm much more comfortable with Cold Fusion, though no more experienced. CF is much more compatible with what I already know and I got the same results with CF in about 1/3 the time it took me in PHP. Unfortunately, CF would require a change of ISP, and I really don't want to change ISPs (that would be a horrible thing, having been with the same ISP since the beginning of 1996). I don't think I want to spend money on a book for a platform that I may discard. Maybe I can negotiate with the ISP (I've done it before in behalf of clients). -- David W. Fenton | http://www.bway.net/~dfenton David Fenton Associates | http://www.bway.net/~dfassoc -- PHP Database 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 Database 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 Database 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 Database 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-DB] Using text files instead of a DB
Sir, you did NOT follow the link I mentioned: http://intercession.net/specialoffers. This offers the web-hosting at %59.40 for the year. Instead you followed the link on http://intercession.net. -Original Message- From: Steve Brett [mailto:[EMAIL PROTECTED]] Sent: Tuesday, March 13, 2001 10:53 AM To: Rick Emery; '[EMAIL PROTECTED]'; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Using text files instead of a DB so ... Virtual Web Site Hosting* 250 MB - $199.99/year one time setup fee. if i divide 199 by 12 i get 5 -Original Message- From: Rick Emery [mailto:[EMAIL PROTECTED]] Sent: 13 March 2001 14:39 To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Using text files instead of a DB I use an ISP (http://intercession.net/specialoffers) who provides PHP and MySQL support on an Apache server (Cobalt Linux) for $5 per month...yes, $5 per month. No extra charges for either. $250 meg space. Full FTP. -Original Message- From: David W. Fenton [mailto:[EMAIL PROTECTED]] Sent: Monday, March 12, 2001 8:41 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Using text files instead of a DB On 12 Mar 01, at 15:30, Phillip Bow wrote: It is absolutely possible though for anything big I would spring for the db access. PHP shares a lot of the functionality that makes Perl a good tool for this type of job so either language is a good choice. For PHP you will want to check out the f-functions(fopen, fread, fwrite), and some of the string manipulation functions(implode, explode, and ereg/preg). Your best bet may be to grab a book that covers string manipulation, and file handling(Wrox Professional PHP programming does I know) to use as reference. So, there's nothing on the web that demonstrates text-file manipulation? OK. I was hoping for an example somewhere that I could dig into and learn from, but if I have to buy a book, well, I'm still trying to figure out if PHP is what I want to use or not. I'm much more comfortable with Cold Fusion, though no more experienced. CF is much more compatible with what I already know and I got the same results with CF in about 1/3 the time it took me in PHP. Unfortunately, CF would require a change of ISP, and I really don't want to change ISPs (that would be a horrible thing, having been with the same ISP since the beginning of 1996). I don't think I want to spend money on a book for a platform that I may discard. Maybe I can negotiate with the ISP (I've done it before in behalf of clients). -- David W. Fenton | http://www.bway.net/~dfenton David Fenton Associates | http://www.bway.net/~dfassoc -- PHP Database 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 Database 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 Database 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-DB] Using text files instead of a DB
On 13 Mar 01, at 9:43, Robert V. Zwink wrote: http://phpclasses.upperdesign.com/browse.html/package/52 Thanks for this. Very simple and straightforward, but I don't see much in there that helps me. The above link will take you to a class to manipulate CSV files. This might help you understand file access in php. If you want to maintain a database within a text file using CSV file format may help. There is not (and will never be) any editing of this text file on the website. It's simply read-only, a periodically uploaded catalog of selected items to allow website viewers to search selected inventory on this client's website: http://www.wurlitzerbruck.com/. If you have specific questions don't hesitate to post. [Keep in mind that I'm an experienced Visual Basic programmer but I've never done very much file I/O and I'm a complete newbie to PHP with no PERL experience, either] I can open the file with fgetcsv(), and there it all is in an array, which is very nice. However, what I really want is to pull only rows matching certain criteria into an array and then display *those*. I've created the data output as a flat file, with the many-to-one data flattened into single fields. [am I correct in surmising that the array created by fgetcsv() is addressable only by index number, and not by column name?] I need to match on: CreatorID (one per row, exact match) CreatorCategories (multiple items per row, match multiple partial strings) KeyWords (multiple items per row, match partial string) Title (one per row, partial match against a concatenation of three columns) The WHERE clause from my ODBC SQL strings would run like this: WHERE (CreatorID IN (232,654,1034)) AND (CreatorCategories Like '%Composer%' OR CreatorCategories Like '%Pianist%') AND (KeyWords Like '%Ballet%' OR KeyWords Like '%Cantatas%' OR KeyWords Like '%Chamber Music%') AND ((BibHeader AutoHeader OtherHeader) Like 'Sonata%') (the example makes no sense, of course, but includes all the possibilities). Now, obviously, I need a regular expression to compare a field value to a list of values, and another to see if any of a list of values is a substring of the field value. Regular expressions always make my eyes glaze over, but these are so simple (aren't they?) that I can't see any examples that I can understand are applicable to what I want -- the examples all seem designed to help you with more complicated tasks than what I need. And, obviously, I want to return just the rows that have a match. If I have the whole file in an array (with fgetcsv()), the row number of the array should be all I need to return, and then I can copy that whole row into a second array. What I'd really like is a way that would selectively copy to an array rather than copying from one big array to a smaller array, but the file has to be open, in memory, either way, right? Or can one read it in one line at a time, test against the conditions, and copy to the array or move on depending on the match? Once the selected rows are in an array, I'm set, since that's a piece of cake. I've read the f functions and the preg and ereg functions, but I'm stuck on: 1. don't know what strategy is best for opening the file. 2. don't know how to construct the needed regular expressions. 3. don't know how to find something in the file with the regex and return a line number (or array number if it's in an array), and then get that line into the array I really want (or just display the results at that point?). Actually, it makes a great deal of sense to fgetcsv() the file, then walk through it testing each row, and outputting only the matches. However, that won't be sorted, so I'd really need to copy the matches into an array where they can be sorted, since the output needs to be sorted. And, of course, in the end, I'll want to deliver results in blocks of 20 per page or so (but I think that can be dealt with by passing a row identifier and the array on to the next page to display; not that I know how to do that, but I can figure it out). Geez. It sounds pretty complicated, after all. Thanks in advance for any help/pointers any of you are able to give. -- David W. Fenton |http://www.bway.net/~dfenton David Fenton Associates |http://www.bway.net/~dfassoc -- PHP Database 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-DB] Using text files instead of a DB
At 09:29 PM 3/12/2001 -0400, you wrote: THE ROTTERS!! They don't have to do ANYTHING to support MySQL except: 1. Set up an empty database 2. Assign it a username/password and, just possibly 3. Provide the most elemental of scripts so you can do a bulk load, thereby creating your tables. For that maybe a $50 one-time charge. $50 per month, never! Working for an ISP as I do, I take great exception to this post. The $50 per month seems rather extravagant (highly depends what you get though) but an extra monthly fee in itself is most definitely not ridiculous or unwarranted. Just because you can download the MySQL server for free does not mean that maintaining the server is free. MySQL is essentially a "smart" file system which allows you to offload disk usage into the MySQL database (depending on where the tables reside). If their pricing structure is disk space related, you can slide content into MySQL without compensating the ISP for it. For most providers, a separate server will need to be setup just for MySQL support. On top of that, MySQL requires a stiff amount of RAM for dealing with larger tables and is yet another service which needs to be monitored on an ongoing basis. Servers cost money and have a limited lifespan. Space, in a climatically controlled environment costs money. Backing up client data costs time and money. As daemon's go it is not horrifically difficult to take care of but still, it does take resources and time and expecting this service for free is unreasonable. At most, you can claim that this company is unrealistic in their pricing structure but there is no shame in charging for a service that costs real money to maintain and support. IMHO of course. Cheers - Island Net AMT Solutions Group Inc. Telephone: 250 383-0096 1412 Quadra Toll Free:1 800 331-3055 Victoria, B.C. Fax:250 383-6698 V8W 2L1 E-Mail:[EMAIL PROTECTED] Canada WWW: http://www.islandnet.com/ - -- PHP Database 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]