<?php echo $post ... not working consistently

Hi, I am setting up a mini forum. When the user names a detailed post, I want them to be able to EDIT the post, when they click edit post page I am using:

<?php echo $post['message']; ?>

this code brings up the message they submitted in their original post so they can edit it.

I am having trouble with trying to do the same for the other fields, ad_type, pet_type, breed, gender, colours, dob, available and price. Here is the code for the edit post page:

if (isset($_GET['action']) && $_GET['action'] == 'edit_post') {
	if ($post['user_id'] != $user_data['user_id'] && $user_data['group_id'] != GROUPS_ADMIN && $user_data['group_id'] != GROUPS_MOD) {
		error('You do not have permission to edit this post!');
	}

	if (!isset($_POST['submit'])) {
		$body->set('post', $post);
		$tpl->set('body', $body->fetch('post_edit.tpl.php'));
	} else {
		$ad_type			= isset($_POST['ad_type']) ? check_input($_POST['ad_type']) : '';
		$pet_type			= isset($_POST['pet_type']) ? check_input($_POST['pet_type']) : '';
		$breed				= isset($_POST['breed']) ? check_input($_POST['breed']) : '';
		$gender				= isset($_POST['gender']) ? check_input($_POST['gender']) : '';
		$colours			= isset($_POST['colours']) ? check_input($_POST['colours']) : '';
		$dob_day			= isset($_POST['dob_day']) && is_numeric($_POST['dob_day']) && $_POST['dob_day'] > 0 && $_POST['dob_day'] <= 31 ? $_POST['dob_day'] : '';
		$dob_month			= isset($_POST['dob_month']) && is_numeric($_POST['dob_month']) && $_POST['dob_month'] > 0 && $_POST['dob_month'] <= 12 ? $_POST['dob_month'] : '';
		$dob_year			= isset($_POST['dob_year']) && is_numeric($_POST['dob_year']) ? $_POST['dob_year'] : '';
		$dob				= $dob_day . '|' . $dob_month . '|' . $dob_year;
		$available_day		= isset($_POST['available_day']) && is_numeric($_POST['available_day']) && $_POST['available_day'] > 0 && $_POST['available_day'] <= 31 ? $_POST['available_day'] : '';
		$available_month	= isset($_POST['available_month']) && is_numeric($_POST['available_month']) && $_POST['available_month'] > 0 && $_POST['available_month'] <= 12 ? $_POST['available_month'] : '';
		$available_year		= isset($_POST['available_year']) && is_numeric($_POST['available_year']) ? $_POST['available_year'] : '';
		$available			= $available_day . '|' . $available_month . '|' . $available_year;
		$price				= isset($_POST['price']) ? check_input($_POST['price']) : '';
		$message			= isset($_POST['message']) ? check_input($_POST['message']) : '';
		$subscribe			= isset($_POST['subscribe']) && $_POST['subscribe'] == 'yes' ? 'yes' : 'no';
		$delete				= isset($_POST['delete']) && $_POST['delete'] == 'yes' ? 'yes' : 'no';

		if ($message == '') {
			error('Your message did not contain any content!');
		}

		$db->query("DELETE FROM " . $config['db']['prefix'] . "forum_subscriptions WHERE user_id = $post[user_id] AND topic_id = $post[topic_id])");

		if ($delete == 'yes') {
			output('Your post has been successfully deleted!');

			if ($post['is_first'] == 1) {
				$result = $db->query("SELECT user_id FROM " . $config['db']['prefix'] . "forum_posts WHERE topic_id = $post[topic_id]");

				while ($user = $db->fetch_array($result)) {
					$db->query("UPDATE " . $config['db']['prefix'] . "users SET num_posts = num_posts - 1 WHERE user_id = $user[user_id]");
				}

				$db->query("DELETE FROM " . $config['db']['prefix'] . "forum_topics WHERE topic_id = $post[topic_id]");
				$db->query("DELETE FROM " . $config['db']['prefix'] . "forum_posts WHERE topic_id = $post[topic_id]");

				redirect('/forum/' . get_url_forum($post['forum_id'], $post['forum_name']), 2);
			} else {
				$db->query("DELETE FROM " . $config['db']['prefix'] . "forum_posts WHERE post_id = $post_id");
				$db->query("UPDATE " . $config['db']['prefix'] . "forum_topics SET num_replies = num_replies - 1 WHERE topic_id = $post[topic_id]");
				$db->query("UPDATE " . $config['db']['prefix'] . "users SET num_posts = num_posts - 1 WHERE user_id = $post[user_id]");

				redirect('/forum/' . get_url_forum($post['forum_id'], $post['forum_name'], $post['topic_id'], $post['subject']), 2);
			}

			update_forum($post['forum_id']);
		} else {
			$db->query("UPDATE " . $config['db']['prefix'] . "forum_posts SET message = '$message' WHERE post_id = $post_id");

			if ($subscribe == 'yes') {
				$db->query("INSERT INTO " . $config['db']['prefix'] . "forum_subscriptions (user_id, topic_id) VALUES ($post[user_id], $post[topic_id])");
			}

			if ($post['is_first'] == 1) {
				$subject			= isset($_POST['subject']) ? check_input($_POST['subject']) : '';
				$topped				= isset($_POST['topped']) && $_POST['topped'] == 'yes' && ($user_data['group_id'] == GROUPS_ADMIN || $user_data['group_id'] == GROUPS_MOD) ? 1 : 0;

				$db->query("UPDATE " . $config['db']['prefix'] . "forum_topics SET subject = '$subject', topped = $topped WHERE topic_id = $post[topic_id]");
			}

			output('Your post has been successfully updated! Please wait while we redirect you to your post.');
			redirect('/forum/' . get_url_forum($post['forum_id'], $post['forum_name'], $post['topic_id'], $post['subject'],  $post_id), 2);
		}
	}
}

I have setup all the correct tables, and installed into MySQL and the data stores in the same place as ‘message’ but every time I use a different variable, eg.

<?php echo $post['price']; ?>

I get this error:

Notice: Undefined index: price in /home/www/templates/forum/post_edit.tpl.php on line 132

Line 32 has this on it

<?php echo $post['price']; ?>

If anyone can spot what I am doing wrong I would really appreciate it. Been staring at my screen for hours trying to solve this :frowning:

Thanks,

Paul

The error is definitely not in the code you posted. Can you post your SQL query where you select the row?

Right, I have looked through everything and I can’t define the exact query. The page is broken down into sections/ New Topic, New Reply, Edit Post etc…

<?php

define('CACHECONTROL', 'private');
define('ROOT_PATH', './../');
require ROOT_PATH . 'includes/common.inc.php';

$tpl	= new template(ROOT_PATH . $config['template_path']);
$body	= new template(ROOT_PATH . $config['template_path'] . 'forum/');

$forum_id	= isset($_REQUEST['forum_id']) && is_numeric($_REQUEST['forum_id']) ? (int) $_REQUEST['forum_id'] : 0;
$topic_id	= isset($_REQUEST['topic_id']) && is_numeric($_REQUEST['topic_id']) ? (int) $_REQUEST['topic_id'] : 0;
$post_id	= isset($_REQUEST['post_id']) && is_numeric($_REQUEST['post_id']) ? (int) $_REQUEST['post_id'] : 0;

if (isset($_GET['action']) && ($_GET['action'] == 'new_topic' || $_GET['action'] == 'new_poll')) {
	$result = $db->query("SELECT forum_id, forum_name FROM " . $config['db']['prefix'] . "forum_forums WHERE forum_id = $forum_id");
	$forum = $db->fetch_array($result);

	$tpl->set('title', $forum['forum_name'] . ' - New ' . ($_GET['action'] == 'new_topic' ? 'Topic' : 'Poll') . ' - ' . $config['site_name']);
	$tpl->set('navigation', '<a href="/">Home</a> &raquo; <a href="/forum/">Forum</a> &raquo; <a href="/forum/' . get_url_forum($forum['forum_id'], $forum['forum_name']) . '">' . $forum['forum_name'] . '</a> &raquo; New ' . ($_GET['action'] == 'new_topic' ? 'Topic' : 'Poll'));
} elseif (isset($_GET['action']) && $_GET['action'] == 'new_reply') {
	$result = $db->query("SELECT t.topic_id, t.forum_id, t.subject, f.forum_name FROM " . $config['db']['prefix'] . "forum_topics t INNER JOIN " . $config['db']['prefix'] . "forum_forums f ON t.forum_id = f.forum_id WHERE t.topic_id = $topic_id");
	$topic = $db->fetch_array($result);

	$tpl->set('title', $topic['subject'] . ' - Reply - ' . $config['site_name']);
	$tpl->set('navigation', '<a href="/">Home</a> &raquo; <a href="/forum/">Forum</a> &raquo; <a href="/forum/' . get_url_forum($topic['forum_id'], $topic['forum_name']) . '">' . $topic['forum_name'] . '</a> &raquo; <a href="/forum/' . get_url_forum($topic['forum_id'], $topic['forum_name'], $topic['topic_id'], $topic['subject']) . '">' . $topic['subject'] . '</a> &raquo; Reply');
} elseif (isset($_GET['action']) && $_GET['action'] == 'move_topic') {
	$result = $db->query("SELECT t.topic_id, t.forum_id, t.subject, f.forum_name FROM " . $config['db']['prefix'] . "forum_topics t INNER JOIN " . $config['db']['prefix'] . "forum_forums f ON t.forum_id = f.forum_id WHERE t.topic_id = $topic_id");
	$topic = $db->fetch_array($result);

	$tpl->set('title', $topic['subject'] . ' - Move - ' . $config['site_name']);
	$tpl->set('navigation', '<a href="/">Home</a> &raquo; <a href="/forum/">Forum</a> &raquo; <a href="/forum/' . get_url_forum($topic['forum_id'], $topic['forum_name']) . '">' . $topic['forum_name'] . '</a> &raquo; <a href="/forum/' . get_url_forum($topic['forum_id'], $topic['forum_name'], $topic['topic_id'], $topic['subject']) . '">' . $topic['subject'] . '</a> &raquo; Move');
} elseif (isset($_GET['action']) && ($_GET['action'] == 'mark_read')) {
	$tpl->set('title', 'Mark topics as read - ' . $config['site_name']);
	$tpl->set('navigation', '<a href="/">Home</a> &raquo; <a href="/forum/">Forum</a> &raquo; Mark topics as read');
} else {
	$result = $db->query("SELECT p.post_id, p.user_id, p.message, p.is_first, p.date_created, t.topic_id, t.subject, t.topped, f.forum_id, f.forum_name, IF(s.topic_id IS NOT NULL, 1, 0) AS subscribed FROM " . $config['db']['prefix'] . "forum_posts p INNER JOIN " . $config['db']['prefix'] . "forum_topics t ON p.topic_id = t.topic_id INNER JOIN " . $config['db']['prefix'] . "forum_forums f ON t.forum_id = f.forum_id LEFT OUTER JOIN " . $config['db']['prefix'] . "forum_subscriptions s ON t.topic_id = s.topic_id AND s.user_id = $user_data[user_id] WHERE p.post_id = $post_id");
	$post = $db->fetch_array($result);

	$tpl->set('title', $post['subject'] . ' - Edit Post - ' . $config['site_name']);
	$tpl->set('navigation', '<a href="/">Home</a> &raquo; <a href="/forum/">Forum</a> &raquo; <a href="/forum/' . get_url_forum($post['forum_id'], $post['forum_name']) . '">' . $post['forum_name'] . '</a> &raquo; <a href="/forum/' . get_url_forum($post['forum_id'], $post['forum_name'], $post['topic_id'], $post['subject']) . '">' . $post['subject'] . '</a> &raquo; Edit Post');
}

if ($user_data['group_id'] == GROUPS_GUEST) {
	error('You must be registered to be able to post! Click <a href="/myaccount/register.htm">here</a> to register. Click <a href="/myaccount/login.htm">here</a> to log in.');
}

// New Topic/Poll

if (isset($_GET['action']) && ($_GET['action'] == 'new_topic' || $_GET['action'] == 'new_poll')) {
	if (!isset($_POST['submit'])) {
		$body->set('forum_id', $forum_id);
		$tpl->set('body', $body->fetch('post_' . ($_GET['action'] == 'new_topic' ? 'topic' : 'poll') . '_new.tpl.php'));
	} else {
		$subject			= isset($_POST['subject']) ? check_input($_POST['subject']) : '';
		$ad_type			= isset($_POST['ad_type']) ? check_input($_POST['ad_type']) : '';
		$pet_type			= isset($_POST['pet_type']) ? check_input($_POST['pet_type']) : '';
		$breed				= isset($_POST['breed']) ? check_input($_POST['breed']) : '';
		$gender				= isset($_POST['gender']) ? check_input($_POST['gender']) : '';
		$colours			= isset($_POST['colours']) ? check_input($_POST['colours']) : '';
		$dob_day			= isset($_POST['dob_day']) && is_numeric($_POST['dob_day']) && $_POST['dob_day'] > 0 && $_POST['dob_day'] <= 31 ? $_POST['dob_day'] : '';
		$dob_month			= isset($_POST['dob_month']) && is_numeric($_POST['dob_month']) && $_POST['dob_month'] > 0 && $_POST['dob_month'] <= 12 ? $_POST['dob_month'] : '';
		$dob_year			= isset($_POST['dob_year']) && is_numeric($_POST['dob_year']) ? $_POST['dob_year'] : '';
		$dob				= $dob_day . '|' . $dob_month . '|' . $dob_year;
		$available_day		= isset($_POST['available_day']) && is_numeric($_POST['available_day']) && $_POST['available_day'] > 0 && $_POST['available_day'] <= 31 ? $_POST['available_day'] : '';
		$available_month	= isset($_POST['available_month']) && is_numeric($_POST['available_month']) && $_POST['available_month'] > 0 && $_POST['available_month'] <= 12 ? $_POST['available_month'] : '';
		$available_year		= isset($_POST['available_year']) && is_numeric($_POST['available_year']) ? $_POST['available_year'] : '';
		$available			= $available_day . '|' . $available_month . '|' . $available_year;
		$price				= isset($_POST['price']) ? check_input($_POST['price']) : '';
		$message			= isset($_POST['message']) ? check_input($_POST['message']) : '';
		$subscribe			= isset($_POST['subscribe']) && $_POST['subscribe'] == 'yes' ? 'yes' : 'no';
		$message			= isset($_POST['message']) ? check_input($_POST['message']) : '';
		$subscribe			= isset($_POST['subscribe']) && $_POST['subscribe'] == 'yes' ? 'yes' : 'no';
		$poll				= isset($_POST['poll']) ? str_replace(array('|', '##'), '', check_input($_POST['poll'])) : '';
		$topped				= isset($_POST['topped']) && $_POST['topped'] == 'yes' && ($user_data['group_id'] == GROUPS_ADMIN || $user_data['group_id'] == GROUPS_MOD) ? 1 : 0;

		if ($subject == '' || $message == '') {
			error('Your subject or message did not contain any content!');
		}

		$poll_answers = '';

		if ($poll != '') {
			foreach (explode("\\\
", $poll) as $answer) {
				$poll_answers .= ($poll_answers != '' ? '##' : '') . str_replace('\\r', '', $answer) . '|0';
			}
		}

		$db->query("INSERT INTO " . $config['db']['prefix'] . "forum_topics (forum_id, user_id, subject, poll, topped, date_created, num_replies, num_views, last_post_date, last_poster_id) VALUES ($forum_id, $user_data[user_id], '$subject', '$poll_answers', $topped, " . time() . ", 0, 0, " . time() . ", $user_data[user_id])");
		$topic_id = $db->insert_id();

		$db->query("INSERT INTO " . $config['db']['prefix'] . "forum_posts (topic_id, user_id, ad_type, pet_type, breed, gender, colours, dob, available, price, message, date_created, is_first) VALUES ($topic_id, $user_data[user_id], '$ad_type', '$pet_type', '$breed', '$gender', '$colours', '$dob', '$available', '$price', '$message', " . time() . ", 1)");
		$post_id = $db->insert_id();

		$db->query("UPDATE " . $config['db']['prefix'] . "forum_topics SET last_post_id = $post_id WHERE topic_id = $topic_id");
		$db->query("UPDATE " . $config['db']['prefix'] . "users SET num_posts = num_posts + 1 WHERE user_id = $user_data[user_id]");

		update_forum($forum_id);
		
		if ($subscribe == 'yes') {
			$db->query("INSERT INTO " . $config['db']['prefix'] . "forum_subscriptions (user_id, topic_id) VALUES ($user_data[user_id], $topic_id)");
		}

		output('Your topic has been successfully submitted! Please wait while we redirect you to your post.');
		redirect('/forum/' . get_url_forum($forum['forum_id'], $forum['forum_name'], $topic_id, $subject), 2);
	}
}

// New Reply

if (isset($_GET['action']) && $_GET['action'] == 'new_reply') {
	if (!isset($_POST['submit'])) {
		if ($post_id != 0) {
			$result = $GLOBALS['db']->query("SELECT message FROM " . $GLOBALS['config']['db']['prefix'] . "forum_posts WHERE post_id = $post_id");
			$body->set('message', $db->result($result, 0));
		}

		$body->set('forum_id', $forum_id);
		$body->set('topic_id', $topic_id);
		$tpl->set('body', $body->fetch('post_reply_new.tpl.php'));
	} else {
		$message	= isset($_POST['message']) ? check_input($_POST['message']) : '';
		$subscribe	= isset($_POST['subscribe']) && $_POST['subscribe'] == 'yes' ? 'yes' : 'no';

		if ($message == '') {
			error('Your message did not contain any content!');
		}

		$db->query("INSERT INTO " . $config['db']['prefix'] . "forum_posts (topic_id, user_id, message, date_created, is_first) VALUES ($topic_id, $user_data[user_id], '$message', " . time() . ", 0)");
		$post_id = $db->insert_id();

		$result = $db->query("SELECT COUNT(post_id) FROM " . $config['db']['prefix'] . "forum_posts WHERE topic_id = $topic_id");
		$num_replies = $db->result($result, 0) - 1;

		$db->query("UPDATE " . $config['db']['prefix'] . "forum_topics SET num_replies = $num_replies, last_post_date = " . time() . ", last_post_id = $post_id, last_poster_id = $user_data[user_id] WHERE topic_id = $topic_id");
		$db->query("UPDATE " . $config['db']['prefix'] . "users SET num_posts = num_posts + 1 WHERE user_id = $user_data[user_id]");

		update_forum($forum_id);

		// Send subscription emails

		$result = $GLOBALS['db']->query("SELECT u.email FROM " . $GLOBALS['config']['db']['prefix'] . "forum_subscriptions s LEFT OUTER JOIN " . $GLOBALS['config']['db']['prefix'] . "users u ON s.user_id = u.user_id WHERE s.topic_id = $topic_id AND s.user_id != $user_data[user_id]");

		while ($user = $GLOBALS['db']->fetch_array($result)) {
			mail($user['email'], 'Reply to ' . $topic['subject'], 'A reply has been made to the post "' . $topic['subject'] . '" on the ' . $config['site_name'] . ' Forum. Click the link below to view the post.' . "\\r\
\\r\
" . $config['site_url'] . 'forum/' . get_url_forum($topic['forum_id'], $topic['forum_name'], $topic['topic_id'], $topic['subject'],  $post_id), 'From: ' . $config['admin_email']);
		}

		if ($subscribe == 'yes') {
			$db->query("INSERT INTO " . $config['db']['prefix'] . "forum_subscriptions (user_id, topic_id) VALUES ($user_data[user_id], $topic_id)");
		}

		output('Your post has been successfully submitted! Please wait while we redirect you to your post.');
		redirect('/forum/' . get_url_forum($topic['forum_id'], $topic['forum_name'], $topic['topic_id'], $topic['subject'],  $post_id), 2);
	}
}

// Edit Post

if (isset($_GET['action']) && $_GET['action'] == 'edit_post') {
	if ($post['user_id'] != $user_data['user_id'] && $user_data['group_id'] != GROUPS_ADMIN && $user_data['group_id'] != GROUPS_MOD) {
		error('You do not have permission to edit this post!');
	}

	if (!isset($_POST['submit'])) {
		$body->set('post', $post);
		$tpl->set('body', $body->fetch('post_edit.tpl.php'));
	} else {
		$ad_type			= isset($_POST['ad_type']) ? check_input($_POST['ad_type']) : '';
		$pet_type			= isset($_POST['pet_type']) ? check_input($_POST['pet_type']) : '';
		$breed				= isset($_POST['breed']) ? check_input($_POST['breed']) : '';
		$gender				= isset($_POST['gender']) ? check_input($_POST['gender']) : '';
		$colours			= isset($_POST['colours']) ? check_input($_POST['colours']) : '';
		$dob_day			= isset($_POST['dob_day']) && is_numeric($_POST['dob_day']) && $_POST['dob_day'] > 0 && $_POST['dob_day'] <= 31 ? $_POST['dob_day'] : '';
		$dob_month			= isset($_POST['dob_month']) && is_numeric($_POST['dob_month']) && $_POST['dob_month'] > 0 && $_POST['dob_month'] <= 12 ? $_POST['dob_month'] : '';
		$dob_year			= isset($_POST['dob_year']) && is_numeric($_POST['dob_year']) ? $_POST['dob_year'] : '';
		$dob				= $dob_day . '|' . $dob_month . '|' . $dob_year;
		$available_day		= isset($_POST['available_day']) && is_numeric($_POST['available_day']) && $_POST['available_day'] > 0 && $_POST['available_day'] <= 31 ? $_POST['available_day'] : '';
		$available_month	= isset($_POST['available_month']) && is_numeric($_POST['available_month']) && $_POST['available_month'] > 0 && $_POST['available_month'] <= 12 ? $_POST['available_month'] : '';
		$available_year		= isset($_POST['available_year']) && is_numeric($_POST['available_year']) ? $_POST['available_year'] : '';
		$available			= $available_day . '|' . $available_month . '|' . $available_year;
		$price				= isset($_POST['price']) ? check_input($_POST['price']) : '';
		$message			= isset($_POST['message']) ? check_input($_POST['message']) : '';
		$subscribe			= isset($_POST['subscribe']) && $_POST['subscribe'] == 'yes' ? 'yes' : 'no';
		$delete				= isset($_POST['delete']) && $_POST['delete'] == 'yes' ? 'yes' : 'no';

		if ($message == '') {
			error('Your message did not contain any content!');
		}

		$db->query("DELETE FROM " . $config['db']['prefix'] . "forum_subscriptions WHERE user_id = $post[user_id] AND topic_id = $post[topic_id])");

		if ($delete == 'yes') {
			output('Your post has been successfully deleted!');

			if ($post['is_first'] == 1) {
				$result = $db->query("SELECT user_id FROM " . $config['db']['prefix'] . "forum_posts WHERE topic_id = $post[topic_id]");

				while ($user = $db->fetch_array($result)) {
					$db->query("UPDATE " . $config['db']['prefix'] . "users SET num_posts = num_posts - 1 WHERE user_id = $user[user_id]");
				}

				$db->query("DELETE FROM " . $config['db']['prefix'] . "forum_topics WHERE topic_id = $post[topic_id]");
				$db->query("DELETE FROM " . $config['db']['prefix'] . "forum_posts WHERE topic_id = $post[topic_id]");

				redirect('/forum/' . get_url_forum($post['forum_id'], $post['forum_name']), 2);
			} else {
				$db->query("DELETE FROM " . $config['db']['prefix'] . "forum_posts WHERE post_id = $post_id");
				$db->query("UPDATE " . $config['db']['prefix'] . "forum_topics SET num_replies = num_replies - 1 WHERE topic_id = $post[topic_id]");
				$db->query("UPDATE " . $config['db']['prefix'] . "users SET num_posts = num_posts - 1 WHERE user_id = $post[user_id]");

				redirect('/forum/' . get_url_forum($post['forum_id'], $post['forum_name'], $post['topic_id'], $post['subject']), 2);
			}

			update_forum($post['forum_id']);
		} else {
			$db->query("UPDATE " . $config['db']['prefix'] . "forum_posts SET message = '$message' WHERE post_id = $post_id");

			if ($subscribe == 'yes') {
				$db->query("INSERT INTO " . $config['db']['prefix'] . "forum_subscriptions (user_id, topic_id) VALUES ($post[user_id], $post[topic_id])");
			}

			if ($post['is_first'] == 1) {
				$subject			= isset($_POST['subject']) ? check_input($_POST['subject']) : '';
				$topped				= isset($_POST['topped']) && $_POST['topped'] == 'yes' && ($user_data['group_id'] == GROUPS_ADMIN || $user_data['group_id'] == GROUPS_MOD) ? 1 : 0;

				$db->query("UPDATE " . $config['db']['prefix'] . "forum_topics SET subject = '$subject', topped = $topped WHERE topic_id = $post[topic_id]");
			}

			output('Your post has been successfully updated! Please wait while we redirect you to your post.');
			redirect('/forum/' . get_url_forum($post['forum_id'], $post['forum_name'], $post['topic_id'], $post['subject'],  $post_id), 2);
		}
	}
}

// Move Topic

if (isset($_GET['action']) && $_GET['action'] == 'move_topic') {
	if ($user_data['group_id'] != GROUPS_ADMIN && $user_data['group_id'] != GROUPS_MOD) {
		error('You do not have permission to move this topic!');
	}
	
	$db->query("UPDATE " . $config['db']['prefix'] . "forum_topics SET forum_id = $forum_id WHERE topic_id = $topic_id");
	
	output('Topic has been successfully moved!');
	redirect('/forum/', 2);
}

// Mark topics as read

if (isset($_GET['action']) && $_GET['action'] == 'mark_read') {
	if ($forum_id == 0) {
		// Loop through all forums and create cookie
		
		$result = $GLOBALS['db']->query("SELECT forum_id FROM " . $GLOBALS['config']['db']['prefix'] . "forum_forums WHERE status = 1");
		
		foreach (fetch_array($result) as $forum) {
			setcookie('f_' . $forum['forum_id'], time(), time() + 86400, $config['cookie']['path'], $config['cookie']['domain']); // 1 day
		}
	
		output('Topics successfully marked as read!');
		redirect('/forum/', 2);
	} else {
		setcookie('f_' . $forum_id, time(), time() + 86400, $config['cookie']['path'], $config['cookie']['domain']); // 1 day
	
		output('Topics successfully marked as read!!');
		redirect('/forum/' . get_url_forum($forum_id, ''), 2);
	}
}

echo $tpl->fetch('forum.tpl.php');

?>

If it’s not in here then magically it just won’t work for me. I’m near on bald now, lol.

Thanks,

Paul

I got this from the MySQL database when I was on the selected table the fields are in:

$sql = 'SELECT * FROM `test_forum_posts` LIMIT 0, 30 ';