red
I have a new problem.
Please remember that I am creating my bulletin board system based off the exercise in chapt. 15 in "Beginning PHP, Apache, MySql, Web Devlopment".
when I want to view forum it uses the viewforum.php file, I get an error that says "Access denied for user: 'frankivey@64.202.167.%' to database 'frankivey'
CREATE TEMPORARY TABLE tmp ( topic_id INT(11) NOT NULL DEFAULT 0, postdate datetime NOT NULL default '0000-00-00 00:00:00')".
I interpret this error as the $sql="CREATE TEMPORARY TABLE tmp ( topic_id INT(11) NOT NULL DEFAULT 0, postdate datetime NOT NULL default '0000-00-00 00:00:00')"; not being read correctly and thus not being able to create this temporary table to show the forum. I also think that the grant tables in my mysql dtabase need to be updated in order to use these commands. I am current using mysql 4.2.00. administrate the database using phpadmin. to see this error live please go to www.practicewebsites.biz and login as frank@yahoo.com and password is "password" and you should be able to see this error.
Did I diagnose this problem correctly?
And if I did how do I correct this problem?
Below I have posted thecode for viewforum.php
VIEWFORUM.PHP
<?php
require_once 'conn.php';
require_once 'functions.php';
require_once 'http.php';
if (!isset($_GET['f'])) redirect('index.php');
require_once 'header.php';
$forumid = $_GET['f'];
$forum = getForum($forumid);
echo breadcrumb($forumid, "F");
if (isset($_GET['page'])) {
$page = $_GET['page'];
} else {
$page = 1;
}
$limit = $admin['pageLimit']['value'];
if ($limit == "") $limit = 25;
$start = ($page - 1) * $admin['pageLimit']['value'];
$sql = "CREATE TEMPORARY TABLE tmp ( ".
"topic_id INT(11) NOT NULL DEFAULT 0, ".
"postdate datetime NOT NULL default '0000-00-00 00:00:00');";
mysql_query($sql) or die(mysql_error()."<br>".$sql);
$sql = "LOCK TABLES forum_users READ,forum_posts READ;";
mysql_query($sql) or die(mysql_error()."<br>".$sql);
$sql = "INSERT INTO tmp SELECT topic_id,MAX(date_posted) ".
"FROM forum_posts ".
"WHERE forum_id = $forumid ".
"AND topic_id > 0 ".
"GROUP BY topic_id;";
mysql_query($sql) or die(mysql_error()."<br>".$sql);
$sql = "UNLOCK TABLES";
mysql_query($sql) or die(mysql_error()."<br>".$sql);
//die('stop');
$sql = "SELECT SQL_CALC_FOUND_ROWS ".
"t.id as topic_id, t.subject as t_subject, ".
"u.name as t_author, count(p.id) as numreplies, ".
"t.date_posted as t_posted, tmp.postdate as re_posted ".
"FROM forum_users u ".
"JOIN forum_posts t ".
"ON t.author_id = u.id ".
"LEFT JOIN tmp ".
"ON t.id = tmp.topic_id ".
"LEFT JOIN forum_posts p ".
"ON p.topic_id = t.id ".
"WHERE t.forum_id = $forumid ".
"AND t.topic_id = 0 ".
"GROUP BY t.id ".
"ORDER BY re_posted DESC " .
"LIMIT $start, $limit";
$result = mysql_query($sql)
or die(mysql_error()."<br>".$sql);
$numrows = mysql_num_rows($result);
if ($numrows == 0) {
$msg = "There are currently no posts. Would you " .
"like to be the first person to create a thread?";
$title = "Welcome to " . $forum['name'];
$dest = "compose.php?forumid=" . $forumid;
$sev = "Info";
$message = msgBox($msg,$title,$dest,$sev);
echo $message;
} else {
if (isset($_SESSION['user_id'])) {
echo topicReplyBar(0, $_GET['f'], "right");
}
echo "<table class='forumtable' cellspacing='0' ";
echo "cellpadding='2'><tr>";
echo "<th class='thread'>Thread</th>";
echo "<th class='author'>Author</th>";
echo "<th class='replies'>Replies</th>";
echo "<th class='lastpost'>Last Post</th>";
echo "</tr>";
while ($row = mysql_fetch_array($result)) {
$rowclass = ($rowclass == "row1"?"row2":"row1");
if ($row['re_posted']=="") {
$lastpost = $row['t_posted'];
} else {
$lastpost = $row['re_posted'];
}
if ((isset($_SESSION['user_id'])) and
($_SESSION['last_login'] < $lastpost)) {
$newpost = true;
} else {
$newpost = false;
}
echo "<tr class='$rowclass'>";
echo "<td class='thread'>".($newpost?NEWPOST." ":"");
echo "<a href='viewtopic.php?t=";
echo $row['topic_id'] . "'>" . $row['t_subject'] . "</a></td>";
echo "<td class='author'>" . $row['t_author'] . "</td>";
echo "<td class='replies'>" . $row['numreplies'] . "</td>";
echo "<td class='lastpost'>" . $lastpost . "</td>";
echo "</tr>\n";
}
echo "</table>";
echo paginate($limit);
echo "<p>".NEWPOST." = New Post(s)</p>";
}
$sql = "DROP TABLE tmp;";
mysql_query($sql) or die(mysql_error()."<br>".$sql);
require_once 'footer.php';
?>
[code=php]
[/COLOR]