Php Forum Code Not Displaying the Forum

Am still a baby so please forgive me for too many Question.
I have a simple forum Script. That is working very fine the problem is with viewing the posted topic
I have 3 major file that anchor the forum my create_topic.php, add_topic.php and main_forum.php. All of them seem fine to except the main_forum.php for it is suppose to display the forum post but when ever i post a topic and try to view it i only get a blank table. The Post are stored in my local host database. These are the Scripts
create_topic.php
[php]

Create New Topic
Topic :
Detail :
Name :
Email :
   
[/php] Next is add_topic.php [php]<?php

$host=“localhost”; // Host name
$username=“root”; // Mysql username
$password=""; // Mysql password
$db_name=“online”; // Database name
$tbl_name=“forum_question”; // Table name

// Connect to server and select database.
mysql_connect("$host", “$username”, “$password”)or die(“cannot connect”);
mysql_select_db("$db_name")or die(“cannot select DB”);

// get data that sent from form
$topic=$_POST[‘topic’];
$detail=$_POST[‘detail’];
$name=$_POST[‘name’];
$email=$_POST[‘email’];

$datetime=date(“d/m/y h:i:s”); //create date time

$sql=“INSERT INTO $tbl_name(topic, detail, name, email, datetime)VALUES(’$topic’, ‘$detail’, ‘$name’, ‘$email’, ‘$datetime’)”;
$result=mysql_query($sql);

if($result){
echo “Successful
”;
echo “View your topic”;
}
else {
echo “ERROR”;
}
mysql_close();
?>[/php]
and finally main_forum.php
[php]<?php

$host=“localhost”; // Host name
$username=“root”; // Mysql username
$password=""; // Mysql password
$db_name=“online”; // Database name
$tbl_name=“forum_question”; // Table name

// Connect to server and select databse.
mysql_connect("$host", “$username”, “$password”)or die(“cannot connect”);
mysql_select_db("$db_name")or die(“cannot select DB”);
$sql=“SELECT * FROM $tbl_name ORDER BY id DESC”;
// OREDER BY id DESC is order result by descending

$result=mysql_query($sql);
?>

<?php // Start looping table row while($rows=mysql_fetch_array($result)){ ?> <?php // Exit looping and close connection } mysql_close(); ?>
# Topic Views Replies Date/Time
<? echo $rows['id']; ?> <? echo $rows['topic']; ?>
<? echo $rows['view']; ?> <? echo $rows['reply']; ?> <? echo $rows['datetime']; ?>
Create New Topic
[/php]

mysql script

Table forum_question
CREATE TABLE `forum_question` (
`id` int(4) NOT NULL auto_increment,
`topic` varchar(255) NOT NULL default '',
`detail` longtext NOT NULL,
`name` varchar(65) NOT NULL default '',
`email` varchar(65) NOT NULL default '',
`datetime` varchar(25) NOT NULL default '',
`view` int(4) NOT NULL default '0',
`reply` int(4) NOT NULL default '0',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;
 
Table forum_answer
CREATE TABLE `forum_answer` (
`question_id` int(4) NOT NULL default '0',
`a_id` int(4) NOT NULL default '0',
`a_name` varchar(65) NOT NULL default '',
`a_email` varchar(65) NOT NULL default '',
`a_answer` longtext NOT NULL,
`a_datetime` varchar(25) NOT NULL default '',
KEY `a_id` (`a_id`)
) TYPE=MyISAM; 

Please My magic Programmers Help me out.Thanks In advance

i have gotten it just change the <? echo to <?php echo
in the main_forum.php :stuck_out_tongue:

Sponsor our Newsletter | Privacy Policy | Terms of Service