当我遇到此错误时,我正在处理论坛脚本
注意:未定义的变量:userids in 第19行的C:\ xampp \ htdocs \ myfolder \ discussion \ post_reply_parse.php “字段列表”中的未知列“电子邮件”
请帮帮我。这是代码
<?php
session_start();
if ($_SESSION['uid']) {
if (isset($_POST['reply_submit'])) {
include_once("connect.php");
$creator = $_SESSION['uid'];
$cid = $_POST['cid'];
$tid = $_POST['tid'];
$reply_content = $_POST['reply_content'];
$sql = "INSERT INTO posts (category_id, topic_id, post_creator, post_content, post_date) VALUES ('".$cid."', '".$tid."', '".$creator."', '".$reply_content."', now())";
$res = mysql_query($sql) or die(mysql_error());
$sql2 = "UPDATE categories SET last_post_date=now(), last_user_posted='".$creator."' WHERE id='".$cid."' LIMIT 1";
$res2 = mysql_query($sql2) or die(mysql_error());
$sql3 = "UPDATE topics SET topic_reply_date=now(), topic_last_user='".$creator."' WHERE id='".$tid."' LIMIT 1";
$res3 = mysql_query($sql3) or die(mysql_error());
$sql4 = "SELECT post_creator FROM posts WHERE category_id='".$cid."' AND topic_id='".$tid."' GROUP BY post_creator";
$res4 = mysql_query($sql4) or die(mysql_error());
while ($row4 = mysql_fetch_assoc($res4)) {
$userids[] .= $row4['post_creator'];
}
foreach ($userids as $key) {
$sql5 = "SELECT id, email FROM users WHERE id='".$key."' AND forum_notification='1' LIMIT 1";
$res5 = mysql_query($sql5) or die(mysql_error());
if (mysql_num_rows($res5) > 0) {
$row5 = mysql_fetch_assoc($res5);
if ($row5['id'] != $creator) {
$email .= $row5['email'].", ";
}
}
}
$email = substr($email, 0, (strlen($email) - 2));
$to = "noreply@somewhere.com";
$from = "YOUR_SITE_EMAIL_HERE";
$bcc = $email;
$subject = "YOUR_SUBJECT_HERE";
$message = "YOU MESSAGE CONTENT HERE";
$headers = "From: $from\r\nReply-To: $from";
$headers .= "\r\nBcc: {$bcc}";
mail($to, $subject, $message, $headers);
if (($res) && ($res2) && ($res3)) {
echo "<p>Your reply has been successfully posted. <a href='view_topic.php?cid=".$cid."&tid=".$tid."'>Click here to return to the topic.</a></p>";
} else {
echo "<p>There was a problem posting your reply. Try again later.</p>";
}
} else {
exit();
}
} else {
exit();
}
?>
答案 0 :(得分:0)
查看users表的结构,并确保为包含电子邮件地址的列使用正确的名称。之后,删除行上的句号
$userids[] .= $row4['post_creator'];
......所以它变成了:
$userids[] = $row4['post_creator'];