• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net

forums not showing...

Cheap Bastard

New Member
http://www.phoenix0.com/zf/index.php

right now it's all just in one page. I'll get it to work with a whole lotta 'include "...";'s later but for now it's in one file (although even if i do use includes it won't be visible to you...)

anyway, here's (pretty much) the code. I left some things out that have nothing to do with the problem.

Oh yea, the problem is that it won't show most variables. I checked with SSH and the tables ARE in fact populated with all the necessary contents.

Also, here's the two tables:

Topic
num, firstposter, timestarted, lastposter,timelastpost, topic, numofposts
Post
Topic, author, time, authorcontents, contents
NOTE: Topic (under post) is a bit misleading... it's just the topic number.

PHP:
case view_topic:
// Shows Topic
$sql = "SELECT * FROM zeroforumstopics WHERE num = \"$topic_num\"";
$result = @mysql_query($sql,$dbconn) or die("Couldn't read database info (zeroforumstopics)");
$row = mysql_fetch_array($result);
$first_poster = $row['firstposter'];
$time_started = $row['timestarted'];
$last_poster = $row['lastposter'];
$time_last_post = $row['timelastpost'];
$topic = $row['topic'];
$number_of_posts = $row['numofposts'];

$table = "<table width=\"95%\" align=center>";
$table .= "<tr><td colspan=2>Topic: $topic_title</td></tr>";

$sql = "SELECT * FROM zeroforumsposts WHERE topic = \"$topicnum\" ORDER BY topic ASC";
$result = @mysql_query($sql,$dbconn) or die("Couldn't read database info (zeroforumsposts)");

while ($row = mysql_fetch_array($result)) {
$topic = $row['topic'];
$author = $row['author'];
$time = $row['time'];
$authorcontents = $row['authorcontents'];
$contents = $row['contents'];

$table .= "<tr><td>$authorcontents</td><td>$contents</td></tr>";
$table .= "<tr><td colspan=2>Posted at $time</td></tr>"; // Author thingies get added here (homepage,...)
}
$table .= "<tr><td colspan=2>Started by $firstposter at $timestarted. Last post by $lastposter at $timelastpost. $number_of_posts posts.</td></tr>";
$table .= "</table>";
$viewing_topic = "1";
break;

case new_topic_form:
// Prints New Topic Form

// $topic_num = FIGURE_OUT_LAST_TOPIC_NUMBER + 1;
$sql = "SELECT num FROM zeroforumstopics ORDER BY num DESC";
$result = @mysql_query($sql,$dbconn) or die("Couldn't read database info");
$row = mysql_fetch_array($result);
$topic_num = $row['num'];
$topic_num = $topic_num + 1;

$table = "<FORM METHOD=POST ACTION=\"$PHP_SELF\">";
$table .= "<input type=\"hidden\" name=\"topic_num\" value=\"$topic_num\">";
$table .= "<input type=\"hidden\" name=\"action\" value=\"new_topic\">";
/*
** start using the one below once you figure out how to authenticate someone (cookies)
** $table .= "<FIELDSET><LEGEND ALIGN=left>Login Info</LEGEND>";
*/
// When you start using the one above, delete the one directly below (just 1 line)
$table .= "<FIELDSET><LEGEND ALIGN=left>Username</LEGEND>";
$table .= "Username: <input type=\"text\" NAME=\"username\" SIZE=20 MAXLENGTH=20><BR>";
// Below is commented out until you figure out how to authenticate someone (cookies)
//$table .= "Password: <input type=\"password\" name=\"passcode\" SIZE=20 MAXLENGTH=20><BR>";
$table .= "</FIELDSET><FIELDSET><LEGEND ALIGN=left>New Topic Contents:</LEGEND>";
$table .= "Topic Title: <input type=\"text\" NAME=\"topic_title\" SIZE=40 MAXLENGTH=40><BR>";
$table .= "<TEXTAREA NAME=\"contents\" ROWS=4 COLS=40 WRAP></TEXTAREA><BR>";
$table .= "</FIELDSET>";
$table .= "<INPUT TYPE=\"submit\" VALUE=\"Post New Topic\">";
break;

case new_topic:
// Adds the new topic with the info given from the New Topic Form

$time = date(Ymd); //DONT FORGET TO ADD HOUR, MINUTES, SECONDS, and FORMATTING!
$authorcontents = $username; 
// Added this so that once there's ranks and stuff the ranks will remain 
// (a person's first post will always have him shown as a rookie)

$sql = "INSERT INTO zeroforumstopics (num,firstposter,timestarted,lastposter,timelastpost,topic,numofposts) VALUES (\"$topic_num\",\"$username\",\"$time\",\"$username\",\"$time\",\"$topic_title\",\"1\")";
$result = @mysql_query($sql,$dbconn) or die("Couldn't insert new_topic values");
$sql = "INSERT INTO zeroforumsposts (topic,author,time,authorcontents,contents) VALUES (\"$topic_num\",\"$username\",\"$time\",\"$authorcontents\",\"$contents\")";
$result = @mysql_query($sql,$dbconn) or die("Couldn't insert new_topic values");

$table = "New Topic posted! Please <a href=\"$PHP_SELF?action=view_topic&topic_num=$topic_num\">Click Here</a> to view your new topic or <a href=\"$PHP_SELF\">Click Here</a> to go back to the forum.<BR>(No really, click either one... No automatic redirection here...)";
break;

case add_reply_form:
// Prints Add Reply Form

$table = "<FORM METHOD=POST ACTION=\"$PHP_SELF\">";
$table .= "<input type=\"hidden\" name=\"topic_num\" value=\"$topic_num\">";
$table .= "<input type=\"hidden\" name=\"action\" value=\"add_reply\">";
/*
** start using the one below once you figure out how to authenticate someone (cookies)
** $table .= "<FIELDSET><LEGEND ALIGN=left>Login Info</LEGEND>";
*/
// When you start using the one above, delete the one directly below (just 1 line)
$table .= "<FIELDSET><LEGEND ALIGN=left>Username</LEGEND>";
$table .= "Username: <input type=\"text\" NAME=\"username\" SIZE=20 MAXLENGTH=20><BR>";
// Below is commented out until you figure out how to authenticate someone (cookies)
//$table .= "Password: <input type=\"password\" name=\"passcode\" SIZE=20 MAXLENGTH=20><BR>";
$table .= "</FIELDSET><FIELDSET><LEGEND ALIGN=left>Reply Contents:</LEGEND>";
$table .= "<TEXTAREA NAME=\"contents\" ROWS=4 COLS=40 WRAP></TEXTAREA><BR>";
$table .= "</FIELDSET>";
$table .= "<INPUT TYPE=\"submit\" VALUE=\"Add Reply\">";
break;

case add_reply:
// Adds the reply with the info given from the Add Reply Form

$time = date(Ymd); //DONT FORGET TO ADD HOUR, MINUTES, SECONDS, and FORMATTING!
$authorcontents = $username; 
// Added this so that once there's ranks and stuff the ranks will remain 
// (a person's first post will always have him shown as a rookie)

$sql = "SELECT numofposts FROM zeroforumstopics WHERE num = \"$topic_num\""; // 4 lines to figure out the new number of posts... pathetic
$result = @mysql_query($sql,$dbconn) or die("Couldn't get the number of posts for this topic (add_reply)");
$row = mysql_fetch_array($result);
$numofposts = $row['numofposts'];
$numofposts = $numofposts + 1;

$sql = "UPDATE zeroforumstopics SET lastposter = \"$username\", timelastpost = \"$time\", numofposts = \"$numofposts\" WHERE num = \"$topic_num\"";
$result = @mysql_query($sql,$dbconn) or die("Couldn't update the topic (add_reply)");
$sql = "INSERT INTO zeroforumsposts (topic,author,time,authorcontents,contents) VALUES (\"$topic_num\",\"$username\",\"$time\",\"$authorcontents\",\"$contents\")";
$result = @mysql_query($sql,$dbconn) or die("Couldn't insert add_reply values");
$table = "Reply added! Please <a href=\"$PHP_SELF?action=view_topic&topic_num=$topic_num\">Click Here</a> to view the new topic or <a href=\"$PHP_SELF\">Click Here</a> to go back to the forum.";
break;
Also, just in case it's important, here's the install part:
PHP:
$creation = "CREATE TABLE zeroforumstopics (num INT,firstposter TINYTEXT,timestarted TINYTEXT,lastposter TINYTEXT,timelastpost TINYTEXT,topic TINYTEXT,numofposts INT)";
@mysql_query($creation,$dbconn) or die("Couldn't create database table zeroforumstopics");

$creation = "CREATE TABLE zeroforumsposts (topic INT,author TINYTEXT,time TINYTEXT,authorcontents TEXT,contents TEXT)";
////////////////////////////
//////////////////////////// MAKE CONTENTS (above) A HUGE TEXT OR SOMETHING BIG...
////////////////////////////
@mysql_query($creation,$dbconn) or die("Couldn't create database table zeroforumsposts");
 
Top