undefined error in creating php forum

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
piano0011
Registered User
Posts: 3
Joined: Mon Mar 19, 2018 11:53 am

undefined error in creating php forum

Post by piano0011 »

Hey guys!

I am trying to create a php forum from following this tutorial:

https://www.youtube.com/watch?v=kpndCNMTiqQ&t=3s

Everything has been working well but I have the following errors:
undefined $userids[].PNG
I am new here, so I am not sure if I should be using backticks to format my code?

Code: Select all

<?php
include_once 'header.php';
if (!isset($_SESSION['u_uid'])) {
	header ("Location: index.php?post_reply_parse=notlogin");
	exit();
	} else {
	if (!isset($_POST['reply_submit'])) {
		header("Location: post_reply.php?post_reply_parse=error");
		exit();

	} else {
		include_once 'includes/dbh.php';
		$date = date("Y-m-d H:i:s");
		$creator = $_SESSION['u_uid'];
		$reply_content = $_POST['reply_content'];
		$cid = $_POST['cid'];
		$tid = $_POST['tid'];
		$limit = 1;

		$sql = "INSERT INTO posts (category_id, topic_id, post_creator, post_content, post_date) VALUES (?,?,?,?,?);";

		if (!mysqli_stmt_prepare($stmt, $sql)) {
				   echo 'SQL error';
				   
				} else {
				    mysqli_stmt_bind_param($stmt, "iisss", $cid, $tid, $creator, $reply_content, $date);
				    mysqli_stmt_execute($stmt);

				    $sql2 = "UPDATE categories
                             SET last_post_date = ?, last_user_posted = ?
                             WHERE id = ?
                             LIMIT ?
				             ";

				    if (!mysqli_stmt_prepare($stmt, $sql2)) {
				   echo 'SQL error';
				   
				} else {
				    mysqli_stmt_bind_param($stmt, "ssii", $date, $creator, $cid, $limit);
				    mysqli_stmt_execute($stmt);

				    $sql3 = "UPDATE topics
                             SET topic_reply_date = ?, topic_last_user = ?
                             WHERE id = ?
                             LIMIT ?
				            ";
                 	if (!mysqli_stmt_prepare($stmt, $sql3)) {
				      echo 'SQL error';
				   
				} else {
				    mysqli_stmt_bind_param($stmt, "ssii", $date, $creator, $tid, $limit);
				    mysqli_stmt_execute($stmt);

				    // Email Sending 

				    $sql4 = "SELECT post_creator FROM posts WHERE category_id = ? AND topic_id = ? GROUP BY post_creator;";

				    if (!mysqli_stmt_prepare($stmt, $sql4)) {
				   echo 'SQL error';
				   
				} else {
				    mysqli_stmt_bind_param($stmt, "ii", $cid, $tid);
				    mysqli_stmt_execute($stmt);
				    $result4 = mysqli_stmt_get_result($stmt);

				    while ($row4 = mysqli_fetch_assoc($result4)) {
                       $userids[] .= $row4['post_creator'];
				    }

				    foreach ($userids as $key) {
				    	$forum_notification = 1;
				    	$limit = 1;

				    	$sql5 = "SELECT user_id, user_uid, user_email FROM users WHERE user_id = ? AND forum_notification = ? LIMIT ?;";

                        if (!mysqli_stmt_prepare($stmt, $sql5)) {
				   echo 'SQL error';
				   
				} else {
				    mysqli_stmt_bind_param($stmt, "iii", $key, $forum_notification, $limit);
				    mysqli_stmt_execute($stmt);
				    $result5 = mysqli_stmt_get_result($stmt);
				    $resultCheck5 = mysqli_num_rows($result5);

				    if ($resultCheck5 > 0) {
                       $row5 = mysqli_fetch_assoc($result5);
                       if ($row5['user_uid'] != $creator) {
                       	   $email .= $row5['user_email'].", ";

                       }
                       
				    } 
				    }

				    $email = substr($email, 0, (strlen($email) - 2));

				    $company = "[email protected]";
                    $subject = "Forum reply";
                    $mailTo = $email;
                    $bcc = $email;
                    $headers = "From: ".$company;
                    $headers .= "\r\nBcc: {$bcc}";
                    $txt = "Hello ".$_SESSION['u_first']." ".$_SESSION['u_last']."! \n\n Someone has replied to a topic you were apart of.";

                    mail($mailTo, $subject, $txt, $headers);


	}

	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>";
}
}
 }
}
}
}
User avatar
Mick
Support Team Member
Support Team Member
Posts: 26505
Joined: Fri Aug 29, 2008 9:49 am

Re: undefined error in creating php forum

Post by Mick »

You should be following the user guide instructions for installing phpBB, no knowledge of programming languages required at all. I really don't know what you're trying to do and why but that video seems to be for PHP and this board is for the support of the phpBB board software. If you can explain exactly what it is you're trying to do we may get a better handle on it, also, please fill out the Support Request Template and post it back here to enable us to assist you better.
  • "The more connected we get the more alone we become" - Kyle Broflovski©
  • "The good news is hell is just the product of a morbid human imagination.
    The bad news is, whatever humans can imagine, they can usually create.
    " - Harmony Cobel
Post Reply

Return to “phpBB Custom Coding”