Faqts : Computers : Programming : Shopping For You : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

25 of 55 people (45%) answered Yes
Recently 4 of 10 people (40%) answered Yes

Entry

How can I use plain txt files instead of a database for a backend of a site, ie managing news posts, uploading files, message boards etc...

Aug 24th, 2009 00:34
Joe Bloggs, healthy man, dman, Dave Kingdon, Jared Mackenzie, http://www.ttnr.org


The key to this problem can be summed up in one word: encoding.
Due to the fact that the structure of the database is also in the 
medium, you have to make sure that you set rules for the structure of 
the file, and then adhere to them in the entire site (otherwise you're 
just making the database flawed, possibly terminally).
Depending on how advanced you are, you could start (quite simply) by 
using a tab-delimited text file for posts:
<id>[  tab  ]<name>[  tab  ]<email>[  tab  ]<homepage>
So the data file would look like:
0    Dave Kingdon    [email protected]    http://lsyg.com
1    Someone Else    [email protected]   http://pmoj.com 
Then, you can use that along with a file for postings:
<id>[  tab  ]<p_id>[  tab  ]<subject>[  tab  ]<date>
0    0    Demonstration file    2000-03-27
1    0    Demonstration file 2  2000-03-27
So you can see from files 1 & 2 that both posts were posted by me.
Now, to make your database driven site a bit quicker, you should make 
yourself some functions (preferrably in an include file for ease) that 
can mimic SQL server functions (in ability as opposed to syntax - I 
take it you're not Stephen Hawking), so you can use other people's 
ideas and pseudocode in developing something really cool.
As for binary files, you can use the built-in base64 encoding function 
(I think I saw one somewhere) to encode binary into text for storage 
(it might be a good idea to put 1 binary file into its own text file so 
it doesn't interfere with your database/text-file layout, and assign it 
its own ID so you can refer to it in your tables).
It may sound daunting, but keep at it.
Dave
======================================
http://www.attorneyslawyersdirectory.com
http://www.findattorneyslawyers.com
http://www.goodlawyersattorneys.com
http://www.professionallawyersattorneys.com
http://www.bestprofessionallawyers.com
http://www.americalawyersattorneys.com
http://www.availablelawyers.com
http://www.lawyersattorneyslist.com
http://www.lawyersattorneysfirm.com
http://www.originallawyers.com
http://www.lawyersgulf.com
http://www.lawyersband.com
http://www.lawyersdatacenter.com
http://www.lawyerstigers.com
http://www.lawcliff.com
http://www.tidylawyers.com
http://www.lawyersblock.com
http://www.californialawyersattorneys.com
http://www.chicagoattorneyslawyers.com
http://www.goodcalifornialawyers.com
http://www.lawyersattorneysfaqs.com
http://www.divorceattorneyslawyers.com
http://www.duiattorneyslawyers.com
http://www.personalinjurylawyerslist.com
http://www.injurylawyersattorneys.com
http://www.dwilawyersattorneys.com
http://www.healthbigboss.com
http://www.healthdohealth.com
http://www.healthcass.com
http://www.healthsilence.com
http://www.healthpicnic.com
http://www.blackmesothelioma.com
http://www.affordablelawyersattorneys.com
http://www.pickarticles.com
http://www.bloodyarticles.com
http://www.healthment.com
http://www.healthbyhealth.com
http://www.ehealthebooks.com
http://www.bestproductsofhealth.com
http://www.dietlosingweight.com
http://www.americanehealth.com
http://www.healthydepartment.com
http://www.medicalehealth.com
http://www.healthservicescenter.com
http://www.ehealthenews.com
http://www.ehealthdept.com
http://www.benefitshealthcenter.com
http://www.toplawyersattorneys.com 
http://www.healthxhealth.com
http://www.mesotheliomakiller.com
http://www.healthinhealth.com
http://www.booksyshop.com
http://www.mesotheliomaout.com
http://www.mesotheliomadown.com
http://www.qwesz.com
http://americanahost.com
http://www.healthfirewall.com
http://www.healthbodyguard.com
http://www.flathealth.com
http://www.computerstan.com
http://www.financestan.com
http://www.technologystan.com
http://www.zobab.com
http://www.businessian.com
http://www.tarabiza.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.hantira.com
http://www.mantofa.com
http://www.tantofa.com
http://www.fantofa.com
http://www.tanpola.com
http://www.tampola.com
http://www.yamot.com
http://www.mozmar.com
http://www.uploadarticles.com
http://www.articlesfreedirectory.com
http://www.articlesxarticles.com
http://www.shikapika.com
http://www.ganazat.com
http://www.stakoza.com
http://www.stupidarticles.com
http://www.damima.com
http://www.halazona.com
======================================