Forum Moderators: coopster
i would like to know if there are anyone out there who knows about a good tutorial for working with text fileas as databses. some more advanced stuff. the thing is i would like to have a php app that allows a user o submit an artice. prety straight forward i guess, but im curious about the way to store it on the server. my free host doesnt allow me to use mysql so i will have to go with text files. say i have a text file for each article. any tips on how to store it so that i can retrive the title and author and data and the data itself easily afterwards?
any tips would be of help
thansk
kumar
anyways...encode the test file as follows
<!--title YOUR TITLE HERE endtitle-->
<!--author AUTOR HERE endauthor-->
this is a sample article
line two
line three
the end
then in your view code write something like this
<?
$grab = "$file.txt"; $read = fopen("$grab", "r"); do {
$data = fread($read, 8192);
if (strlen($data) == 0) { break; }
$contents .= $data;
} while(true);
fclose ($read);
echo "<html><body bgcolor=blue><h1 align=center>";
if(ereg("<!--title(.*)endtitle-->", $contents, $out)){
echo $out;
} else { echo "File $file"; }
echo "</h1>"; error_reporting(0);
do { $data = fread($read, 8192);
if (strlen($data) == 0) { break; }
$contents .= $data;
} while(true);
fclose ($read);
if(ereg("<!--author(.*)endauthor-->", $contents, $out)){ echo "<p align=center><i>By: "; echo $out[1]; echo"</i></p>"; }
echo "<hr><pre>";
include("$file.txt");
echo "</pre></body></html>";
?>
xml is probobly more efficient...but this is easier