Results 1 to 5 of 5

Thread: Can't see new thread in the tutorial I am trying out

  1. #1
    Join Date
    Apr 2008
    Posts
    19
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Default Can't see new thread in the tutorial I am trying out

    Hi there!

    I hope that this is the right place to post this. Am trying my hands in creating a simple forum. Came across this tutorial at http://stupidphp.blogspot.com/2008/0...-tutorial.html

    Question:
    When I tried out the forum and posted a new topic, I got this message - Successful. View your topic.
    However, when I click on the "view your topic", I could NOT see my topic which I posted.
    But, when I checked my PHPMyAdmin database, I can see my topic there.
    How come? Am so puzzled. :?: :?: :?: :?:

    Can someone please help me?

    Thanks so much!

    JP

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Post your add_topic.php and view_topic.php.
    Make sure you didn't remove any thing from view_topic, or add_topic(most likely view_topic though).
    Jeremy | jfein.net

  3. The Following User Says Thank You to Nile For This Useful Post:

    jadepearl (09-30-2008)

  4. #3
    Join Date
    Apr 2008
    Posts
    19
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Default

    Hi Nile,

    You mean you want me to post the codes of the two files here?

    When I try to view the view_topic.php file, this is the message appeared.

    Parse error: syntax error, unexpected $end in C:\wamp\www\website\view_topic.php on line 148

    Thanks for your help.

    Regards,
    JP

  5. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    I want to see the codes, correct. Not the output, looking at your post above this one, it's an easy fix...
    Jeremy | jfein.net

  6. The Following User Says Thank You to Nile For This Useful Post:

    jadepearl (09-30-2008)

  7. #5
    Join Date
    Apr 2008
    Posts
    19
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Default

    Hi Nile,

    OK...I understand now.

    Here's my add_topic codes:
    PHP Code:
    <?php
    $host
    ="localhost"// Host name
    $username="myusername"// Mysql username
    $password="mypassword"// Mysql password
    $db_name="test"// 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<BR>";
    echo 
    "<a href=main_forum.php>View your topic</a>";
    }
    else {
    echo 
    "ERROR";
    }
    mysql_close();
    ?>
    And here's my view_topic codes:
    PHP Code:
    <?php
    $host
    ="localhost"// Host name
    $username="myusername"// Mysql username
    $password="mypassword"// 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");

    // get value of id that sent from address bar
    $id=$_GET['id'];

    $sql="SELECT * FROM $tbl_name WHERE id='$id'";
    $result=mysql_query($sql);

    $rows=mysql_fetch_array($result);
    ?>
    <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
    <tr>
    <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bordercolor="1" bgcolor="#FFFFFF">
    <tr>
    <td bgcolor="#F8F7F1"><strong><? echo $rows['topic']; ?></strong></td>
    </tr>

    <tr>
    <td bgcolor="#F8F7F1"><? echo $rows['detail']; ?></td>
    </tr>

    <tr>
    <td bgcolor="#F8F7F1"><strong>By :</strong> <? echo $rows['name']; ?> <strong>Email : </strong><? echo $rows['email'];?></td>
    </tr>

    <tr>
    <td bgcolor="#F8F7F1"><strong>Date/time : </strong><? echo $rows['datetime']; ?></td>
    </tr>
    </table></td>
    </tr>
    </table>
    <BR>
    <?php
    $tbl_name2
    ="forum_answer"// Switch to table "forum_answer"

    $sql2="SELECT * FROM $tbl_name2 WHERE question_id='$id'";
    $result2=mysql_query($sql2);

    while(
    $rows=mysql_fetch_array($result2)){
    ?>
    <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
    <tr>
    <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
    <tr>
    <td bgcolor="#F8F7F1"><strong>ID</strong></td>
    <td bgcolor="#F8F7F1">:</td>
    <td bgcolor="#F8F7F1"><? echo $rows['a_id']; ?></td>
    </tr>
    <tr>
    <td width="18%" bgcolor="#F8F7F1"><strong>Name</strong></td>
    <td width="5%" bgcolor="#F8F7F1">:</td>
    <td width="77%" bgcolor="#F8F7F1"><? echo $rows['a_name']; ?></td>
    </tr>
    <tr>
    <td bgcolor="#F8F7F1"><strong>Email</strong></td>
    <td bgcolor="#F8F7F1">:</td>
    <td bgcolor="#F8F7F1"><? echo $rows['a_email']; ?></td>
    </tr>
    <tr>
    <td bgcolor="#F8F7F1"><strong>Answer</strong></td>
    <td bgcolor="#F8F7F1">:</td>
    <td bgcolor="#F8F7F1"><? echo $rows['a_answer']; ?></td>
    </tr>
    <tr>
    <td bgcolor="#F8F7F1"><strong>Date/Time</strong></td>
    <td bgcolor="#F8F7F1">:</td>
    <td bgcolor="#F8F7F1"><? echo $rows['a_datetime']; ?></td>
    </tr>
    </table></td>
    </tr>
    </table><br>

    <?
    }

    $sql3="SELECT view FROM $tbl_name WHERE id='$id'";
    $result3=mysql_query($sql3);

    $rows=mysql_fetch_array($result3);
    $view=$rows['view'];

    // if have no counter value set counter = 1
    if(empty($view)){
    $view=1;
    $sql4="INSERT INTO $tbl_name(view) VALUES('$view') WHERE id='$id'";
    $result4=mysql_query($sql4);
    }

    // count more value
    $addview=$view+1;
    $sql5="update $tbl_name set view='$addview' WHERE id='$id'";
    $result5=mysql_query($sql5);

    mysql_close();
    ?>
    <BR>
    <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
    <tr>
    <form name="form1" method="post" action="add_answer.php">
    <td>
    <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
    <tr>
    <td width="18%"><strong>Name</strong></td>
    <td width="3%">:</td>
    <td width="79%"><input name="a_name" type="text" id="a_name" size="45"></td>
    </tr>
    <tr>
    <td><strong>Email</strong></td>
    <td>:</td>
    <td><input name="a_email" type="text" id="a_email" size="45"></td>
    </tr>
    <tr>
    <td valign="top"><strong>Answer</strong></td>
    <td valign="top">:</td>
    <td><textarea name="a_answer" cols="45" rows="3" id="a_answer"></textarea></td>
    </tr>
    <tr>
    <td> </td>
    <td><input name="id" type="hidden" value="<? echo $id?>"></td>
    <td><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"></td>
    </tr>
    </table>
    </td>
    </form>
    </tr>
    </table>
    I did not remove anything.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •