Hello, i had this php script running fine on the server for a year, now all of
a sudden its not working and im getting this error message:
Warning: Variable passed to each() is not an array or object in
/home1/website/public_html/maila.php on line 37
Warning: Cannot modify header information - headers already sent by (output
started at /home1/website/public_html/maila.php:37) in
/home1/website/public_html/maila.php on line 45
All the script does is filter words from a form, writes them to a flat file,
emails the comment to me then redirects back to display the comment to the
user.
Here is my code that was working and now does not, i played with it for hours
with no luck, if i commented out line 37 then it would work but it sends a
blank e-mail to me, any help i would be grateful for, thanks.
<code>
<?
$post = $POST['comments'];
if (!$post){
header("Location: webpage.php");
exit();
}
if (strlen($POST['comments']) > 208) {
header("Location: webpage.php");
exit();
}
$words = array('unwanted words for array put here', );
$continue = true;
foreach ($words as $word) {
if (preg_match('/\b' . $word . '\b/i', $post)) {
$continue = false;
header("Location: webpage.php");
exit();
}
}
if (!$continue) {
echo 'Bad boy!';
} else {
$fc = fopen("comments.txt","a+b"); //opens the file to append new comment -
fputs($fc,$_POST['comments']."\n\n\nNewComment->"); //writes the comments
fclose($fc); //closes the files
if(sizeof($_POST)) {
$body = "";
while(list($key, $val) = each($HTTP_POST_VARS)) { //<--Line 37
$body .= "$key: $val \n";
}
mail("my-email@aol.com", // to
"Subject Line",
$body);
header("Location: webpage.php");
}
} //<--Line 48
</code>