Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 18

Thread: PHP? Help

  1. #1
    Banned
    Join Date
    Feb 2008
    Location
    USA
    Posts
    61
    Thanks
    15
    Thanked 1 Time in 1 Post

    PHP? Help

    I want it where that page exists but in a way it doesn't.

    Just like other forums...

    You view the subject of topics right? The topic you wanna see you click it and it brings you to that page.
    What I have is where you see the topics but when you click into it it goes to a blank page when It should be the page that they wanted to see.

    That's it. here is the code to where you click the topic you want:

    PHP Code:
    echo ''.$row['subject']. "<a href='http://www.frazierfilms.fragvault.com/forum/showtopic.php?id='>Go to the topic</a>"
    And here is the code that IS the page that gets the message of which topic you clicked:

    PHP Code:
    <?php
    $id 
    $_GET['id'];
    $message $_GET['message'];
    $id mysql_real_escape_string($id);
    $message mysql_real_escape_string($message);
    // Get all the data from the "example" table
    $result mysql_query("SELECT * FROM topics WHERE `id`='$id'"
    or die(
    mysql_error());  


    echo 
    " <table border='1' 'width = 92%' > ";

    echo 
    "<tr> <th>Shows</tr>";
    // keeps getting the next row until there are no more to get
    while($row mysql_fetch_array$result )) { 
        
    // Print out the contents of each row into a table
        
    echo "<tr><td>"
        echo 
    ''.$row['message'];
        echo 
    "</td></tr>"


    echo 
    "</table>";
    ?>
    Please help, thanks
    Last edited by Dfraz; 02-21-2008 at 06:25 AM.

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    do you mean that when you click on "Go to topic" you see the php code?

    best regards

  • #3
    Banned
    Join Date
    Feb 2008
    Location
    USA
    Posts
    61
    Thanks
    15
    Thanked 1 Time in 1 Post
    I mean where when you click into the topic it views the message and stuff just like normal forums.
    You click into THIS topic and see what we've said. That is what I mean!

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Dfraz View Post
    I mean where when you click into the topic it views the message and stuff just like normal forums.
    You click into THIS topic and see what we've said. That is what I mean!
    THIS must be your thread on codingforums?

    best regards

  • #5
    Banned
    Join Date
    Feb 2008
    Location
    USA
    Posts
    61
    Thanks
    15
    Thanked 1 Time in 1 Post
    Right it is. Just please tell me how I can do that. Edit the code and fix it please.

  • #6
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    You need the id of the thread. You don't seem to have that in your code. We can't tell what the id of the thread is of your specific forum. Also we are here to help you but if you don't give enough information to help you we can't. We aren't here to just fix things for you because you didn't try to.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #7
    Banned
    Join Date
    Feb 2008
    Location
    USA
    Posts
    61
    Thanks
    15
    Thanked 1 Time in 1 Post
    I understand.

    But I've been trying for more then 3 hours straight!

    I edited the post I think and I think I put it right.

    But when I click the topic I want the description is EMPTY.
    Here take a try. http://www.frazierfilms.fragvault.co...m/athreads.php

  • #8
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Your query should probably be failing as id is a likely an integer not a string. Try
    PHP Code:
    <?php
    $id 
    '';
    if(isset(
    $_GET['id']))
    {
    $id intval($_GET['id']);
    }
    // Get all the data from the "example" table
    $result mysql_query("SELECT * FROM topics WHERE `id`= $id") or die(mysql_error());  


    echo 
    " <table border='1' width = '92%' > ";

    echo 
    "<tr> <th>Shows</tr>";
    // keeps getting the next row until there are no more to get
    while($row mysql_fetch_array$result )) { 
        
    // Print out the contents of each row into a table
        
    echo "<tr><td>"
        echo 
    $row['message'];
        echo 
    "</td></tr>"


    echo 
    "</table>";
    ?>
    Make sure you are connecting to the database properly as well. You aren't using $_GET['message'] anywhere in your query so you don't need it. Why are you trying to make your own forum? Its clear that you aren't that experienced yet. You are better off downloading and installing an existing forum like phpbb or something.
    Last edited by _Aerospace_Eng_; 02-21-2008 at 06:50 AM.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #9
    Banned
    Join Date
    Feb 2008
    Location
    USA
    Posts
    61
    Thanks
    15
    Thanked 1 Time in 1 Post
    Now it says
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

  • #10
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Right because you aren't passing anything to the url. You NEED to pass the id of the thread to the url. Try this
    PHP Code:
    <?php
    $id 
    = (isset($_GET['id'])) ? intval($_GET['id']) : 1;

    // Get all the data from the "example" table
    $result mysql_query("SELECT * FROM topics WHERE `id`= $id") or die(mysql_error());  


    echo 
    " <table border='1' width = '92%' > ";

    echo 
    "<tr> <th>Shows</tr>";
    // keeps getting the next row until there are no more to get
    while($row mysql_fetch_array$result )) { 
        
    // Print out the contents of each row into a table
        
    echo "<tr><td>"
        echo 
    $row['message'];
        echo 
    "</td></tr>"


    echo 
    "</table>";
    ?>
    Its probably still not going to bring anything up because you need to give it a valid id of a thread. So now go into your database and get an id from a thread and then use the url
    http://www.yoursite.com/showthread.php?id=12345 where 12345 is the id you got from the database.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #11
    Banned
    Join Date
    Feb 2008
    Location
    USA
    Posts
    61
    Thanks
    15
    Thanked 1 Time in 1 Post
    Now it works but it's empty.

    It should have whatever the user put for the message

  • #12
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    I don't think you understand how databases work. The user submits a post, the post goes into the database with an id. Then the page is called with the id as a query string. The id is used to pull the correct message from the database. If you don't store the message anywhere its not going to show up. So now WHAT is in your database? Do you even have one?
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #13
    Banned
    Join Date
    Feb 2008
    Location
    USA
    Posts
    61
    Thanks
    15
    Thanked 1 Time in 1 Post
    I have a database.
    I have it to insert into the database.
    I have a ID, Message and Subject column in my database.

    And now all I'm trying to do is get it to view the topic I want it to view.

    EXAMPLE!!!

    When I click into this topic I want to see what I've said.
    In the case I've got on mine now. You click in the topic and it's completly Empty.

  • #14
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Okay the code above is what page? What is the url to that page? Also do you HAVE an ID of a message in your database? If so what is it?
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #15
    Banned
    Join Date
    Feb 2008
    Location
    USA
    Posts
    61
    Thanks
    15
    Thanked 1 Time in 1 Post
    The Ids
    Are.
    10

    and

    11

    the url is: frazierfilms.fragvault.com/showtopic.php


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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