I'm building a forum(at least trying) which store entrys to a file. I cant seem to figure out a way to write replys to existing entrys. Is this possible to do this? I can write to the front of the file without problems. This is one of those old school forums, with the individual hyperlinks that call a page to display a specific entry. Here's my code to add a entry to the front... How would I modify it to add one in the middle?
echo "MSG submitted!!!";
$file = join("", file($msgfile));
$fp = fopen($msgfile, "w");
$now = (time() - 5*3600);
$now = date("g:i a, F jS, Y ", $now);
fputs($fp, "|$subject|$Icon|$name|$now|$site|$message|$REMOTE_ADDR|\n");
fputs($fp, $file);
fclose($fp);
Any ideas?
Thanks!very messy to do it in flat files. best bet is to use a database like mysql.
you can open the file and get all of teh contents in an aray adn then search for a specific element then cut it right tehre adn then add stuff to it and add it back to the array. very tricky and messy. then if you have multiple people doing that to the same file you will have problems. lahtough you could use flock() but it still creates a problem.
echo "MSG submitted!!!";
$file = join("", file($msgfile));
$fp = fopen($msgfile, "w");
$now = (time() - 5*3600);
$now = date("g:i a, F jS, Y ", $now);
fputs($fp, "|$subject|$Icon|$name|$now|$site|$message|$REMOTE_ADDR|\n");
fputs($fp, $file);
fclose($fp);
Any ideas?
Thanks!very messy to do it in flat files. best bet is to use a database like mysql.
you can open the file and get all of teh contents in an aray adn then search for a specific element then cut it right tehre adn then add stuff to it and add it back to the array. very tricky and messy. then if you have multiple people doing that to the same file you will have problems. lahtough you could use flock() but it still creates a problem.