Posted this awhile back, hasen't been fixed, but I tried and tried my best, no luck, so now, I cleaned it down to just the bare bones to make debugging easier, and need your help.
<?php
if ($userid <> "NULL")
{
if(isset($_POST["newtopic"]))
{
$f = $_POST["fid"];
$post = $_POST["reply"];
$topicname = $_POST["tname"];
$description = $_POST["tdesc"];
$replyFile = fopen ("../data/forum{$f}.txt", "r");
foreach($replyFile as $reply) {
$replyparts = explode ("|", $reply);
$tid = trim($replyparts[0]);
$tid = $tid + 1;
fclose($replyFile);
$postFile = fopen ("../data/forum".$f.".txt", "r+");
fwrite($postFile, "\n$tid|$topicname|$description|$post|$id|0|0|-");
fclose($postFile);
header("Location: ".$HTTP_SERVER_VARS['HTTP_HOST']."/forums/index.php?act=rtopic&f={$f}&id={$tid}");
}
}
}
else
{
echo "<div align='center'>";
echo "<table border='1' cellspacing='0' width='158' height='36'>";
echo " <tr>";
echo " <td width='158' height='36'><p align='center'>Error: Not logged in!</td>";
echo " </tr>";
echo "</table>";
echo "</div>";
echo "</font>";
}
?>
Here's the error: Warning: Invalid argument supplied for foreach() in /home/virtual/site18/fst/var/www/html/forums/process/newtopic.php on line 11
I really need help on this. Thanks.