[thelist] php writing to a file

Steve Cook steve.cook at evitbe.com
Thu May 23 04:21:01 CDT 2002


What you are describing screams for a database solution. If you are not tied
down to using a file-based system, then start looking at a simple database
table to handle the information. Any basic introduction to working with
databases in PHP should give you all the ammunition to code this.

The reason I recommend a database is that it is built from the ground up to
handle this sort of information. Using text files in this way (often
referred to as using a "flat file database") is very possible, but is an
absolute pain in the rear to maintain. I have built similar systems in the
past and each and every time the support of the system was monstrous. In
addition, code to add information, retrieve information and change
information would require a huge amount of code compared to using a
database, which will automate all these jobs and more.

If you are limited to a server that does not give you Database access, then
I would suggest the following Google searches:
http://www.google.com/search?hl=en&lr=&ie=UTF8&oe=UTF8&q=flat+file+php
http://www.google.com/search?hl=en&ie=UTF8&oe=UTF8&q=flat+file+database+php

Here you will find resources to get you on your way. However, if you have
the chance to implement this using databases, then I would say that the time
spent learning the basic principles of database manipulation will be well
spent and will save you from the headaches of supporting a flat-file system.
Here's a good tutorial link:
http://www.blazonry.com/scripting/linksdb/index.php
though you'll find hundreds of others here...
http://www.google.com/search?hl=en&lr=&ie=UTF8&oe=UTF8&q=php+database+tutori
al

Good luck!!

.steve


----------------------------------
 Cookstour - http://cookstour.org
----------------------------------
> -----Original Message-----
> From: Andrew Maynes [mailto:andrew at uk-webdeveloper.co.uk]
> Sent: den 23 maj 2002 10:52
> To: Thelist at Lists. Evolt. Org
> Subject: [thelist] php writing to a file
>
>
> Some while back I asked to write form information into a file
> and was provided
> with this
>
> $string = implode("\t",$_POST);
> $fp = fopen("file.txt","w");
> fwrite($fp,$product);
> fclose($fp);
>
> it seems this can sit anywhere in the form.  It does write to
> a file called
> file.txt
>
> However, this aint a solution.  I need for each different
> user to be able to
> write to a different file and inparticular to be able to
> identify with that file
> later specifically in assocaition with the user who submitted
> the info :) does
> that make sense?
>



More information about the thelist mailing list