legomaniac25 Posted May 29, 2007 Share Posted May 29, 2007 Hey guys, I am trying to get a simple forum to work and I am having trouble with some of the code that I found <?php $host="localhost"; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name="test"; // 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); ?> <table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td width="6%" align="center" bgcolor="#E6E6E6"><strong>#</strong></td> <td width="53%" align="center" bgcolor="#E6E6E6"><strong>Topic</strong></td> <td width="15%" align="center" bgcolor="#E6E6E6"><strong>Views</strong></td> <td width="13%" align="center" bgcolor="#E6E6E6"><strong>Replies</strong></td> <td width="13%" align="center" bgcolor="#E6E6E6"><strong>Date/Time</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ // Start looping table row ?> <tr> <td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td> <td bgcolor="#FFFFFF"><a href="view_topic.php?id=<? echo $rows['id']; ?>"><? echo $rows['topic']; ?></a><BR></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['view']; ?></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['reply']; ?></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['datetime']; ?></td> </tr> <?php // Exit looping and close connection } mysql_close(); ?> <tr> <td colspan="5" align="right" bgcolor="#E6E6E6"><a href="create_topic.php"><strong>Create New Topic</strong> </a></td> </tr> </table> That is the code I am having trouble with. The forum is at the following link: http://69.146.93.249:81/main_forum.php As you can see when I tried to add topics it added a new row to the table but did not put any info in the row. I can see the data while browsing the mysql database with phpmyadmin but I cannot seem to access any of the data when I try to access it through main_forum.php create_topic.php is the directory for the topic creation part of the forum Is there some code that is missing or does anyone have any idea what is wrong? Thank you in advance for your help! Quote Link to comment https://forums.phpfreaks.com/topic/53350-problem-with-simple-forum-code/ Share on other sites More sharing options...
dustinnoe Posted May 29, 2007 Share Posted May 29, 2007 Your server may not recognize the php short tags. Use <?php instead of <? when echoing variables. Quote Link to comment https://forums.phpfreaks.com/topic/53350-problem-with-simple-forum-code/#findComment-263678 Share on other sites More sharing options...
gabeg Posted May 29, 2007 Share Posted May 29, 2007 Your server may not recognize the php short tags. Use <?php instead of <? when echoing variables. [/quote Agreed, because when I made a new topic, it added a blank row to the table. Quote Link to comment https://forums.phpfreaks.com/topic/53350-problem-with-simple-forum-code/#findComment-263687 Share on other sites More sharing options...
legomaniac25 Posted May 29, 2007 Author Share Posted May 29, 2007 yeah, i'm such a noob that worked great I actually just copied and pasted all of the text into word and then used the find and replace feature to put the extra "php" in to all the code you guys rock, thanks for helping me and not dissing me for asking such a simple question, there are places that will just not answer if you don't know enough. php is new to me but I am ace at photoshop and I am helping people on forums all the time, it's nice to know that there are other people out there like me who actually try to help newbs thanks again, much appreciated, it works great with my wamp now edit: oh and it looks as though I can't edit my first post now, and because I have no use for it can a mod remove the link in the first post please? thanks again guys Quote Link to comment https://forums.phpfreaks.com/topic/53350-problem-with-simple-forum-code/#findComment-263689 Share on other sites More sharing options...
dream25 Posted May 29, 2007 Share Posted May 29, 2007 Hi.. logomaniac.. i need ur help.. im also trying to code for forums for my project,, if u dont mind will u plz send ur codings about ur forums.. i think it will help me.. will u plz.. Thanks in advance.. Uday Quote Link to comment https://forums.phpfreaks.com/topic/53350-problem-with-simple-forum-code/#findComment-263717 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.