SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: $_GET troubles

  1. #1
    SitePoint Member Borgscan's Avatar
    Join Date
    Sep 2004
    Location
    Australia
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $_GET troubles

    Hello everyone, I'm new to being a registered here - long time reader, short time poster

    I was hoping that someone out there could assist me with this script that I wrote. It's for a forum (my own forum not a board such as VBulletin) The categorie listing works, however when a forum is clicked it displays all the active topics from MYSQL that are NOT assigned to the requeted forum id. Meaning it doest he oppisite to what it should. Does what I'm saying make sense?

    It does seem to be a problem with...

    Code:
    $forum_id = $_GET["forum_id"];
    The full script...

    Code:
    <?php
    
    session_start();
    
    include "config.php";
    include "header.php"; //html + css info
    
    if ($_GET["idx"] == ""){
    
    echo "<font class=\"font_title\"><center>Please be advised, this section is under constuction!</font>
    <br><br>";
    
    $sql1 = "SELECT * FROM forum_categories WHERE active = 'yes' ORDER BY id"; 
    $result1 = mysql_query($sql1);
    $c=0;
    while ($row1 = mysql_fetch_array($result1)){
    
    $cat_id		=	$row1["id"];
    $cat_title	= 	$row1["title"];
    
    echo "<table width=\"96%\" align=\"center\" border=\"1\" bordercolor=\"993366\" cellspacing=\"0\" 
    cellpadding=\"5\"><tr><td width=\"100%\" colspan=\"3\" nowrap=\"nowrap\">
    <font class=\"font_title\">&gt; $cat_title</font></td></tr><tr><td align=\"center\" nowrap=\"nowrap\">
    <font class=\"font\">Status</font></td><td width=\"50%\" align=\"center\" nowrap=\"nowrap\">
    <font class=\"font\">Forum Title</font></td><td width=\"25%\" align=\"center\" nowrap=\"nowrap\">
    <font class=\"font\">Last Post</font></td></tr>";
    
    $sql2 = "SELECT * FROM forum_forums WHERE active = 'yes' AND cat_id = '$cat_id' ORDER BY id"; 
    $result2 = mysql_query($sql2);
    $row2 = mysql_fetch_array($result2);
    
    $forum_id		=	$row2["id"];
    $forum_title 	=	$row2["title"];
    $forum_details	=	$row2["details"];
    $forum_image	=	$row2["image"];
    $forum_status	=	$row2["status"];
    
    $sql3 = "SELECT * FROM forum_topics WHERE active = 'yes' AND forum_id = '$forum_id' ORDER BY id DESC" ; 
    $result3 = mysql_query($sql3);
    $row3 = mysql_fetch_array($result3);
    
    $topic_id		=	$row3["id"];
    $topic_title 	=	$row3["title"];
    $topic_author	=	$row3["author"];
    $topic_status	=	$row3["status"];
    
    $sql4 = "SELECT * FROM forum_posts WHERE topic_id = '$topic_id' ORDER BY id DESC" ; 
    $result4 = mysql_query($sql4);
    $row4 = mysql_fetch_array($result4);
    
    $last_author	=	$row4["author"];
    $last_date		=	$row4["date"];
    $last_time		=	$row4["time"];
    
    echo "<tr><td align=\"center\"><img src=\skin/$skin/images/forum/$forum_image\ alt=\"Forum\">";
    
    echo "<td><font class=\"font\"><a href=\"forum.php?idx=forum&id=$forum_id\">$forum_title</a></font>";
    
    echo "<br><font class=\"font\">$forum_details</font></td>";
    
    echo "<td nowrap=\"nowrap\"><a href=\"forum.php?idx=topic=$topic_id&page=last\">$last_date - $last_time</a>
    <br><font class=\"font\">By: </font><a href='profile.php?name=$last_author'>$last_author</a>
    </td></tr></table><br>";
    $c++;
    }
    }
    
    
    if ($_GET["idx"] == "forum"){
    
    $forum_id = $_GET["forum_id"];
    
    $sql5 = "SELECT * FROM forum_topics WHERE forum_id = '$forum_id' AND active = 'yes' ORDER BY id"; 
    $result5 = mysql_query($sql5);
    $f=0;
    while ($mytopicrow5 = mysql_fetch_array($result5)){
    
    $topic_id		=	$mytopicrow5["id"];
    $topic_title	=	$mytopicrow5["title"];
    $topic_starter	=	$mytopicrow5["starter"];
    $topic_status	=	$mytopicrow5["status"];
    
    $sql6 = "SELECT * FROM forum_posts WHERE active = 'yes' AND topic_id = '".$topic_id."' ORDER BY id DESC" ; 
    $result6 = mysql_query($sql6);
    $mytopicrow6 = mysql_fetch_array($result6);
    
    $last_author	=	$mytopicrow6["author"];
    $last_date		=	$mytopicrow6["date"];
    $last_time		=	$mytopicrow6["time"];
    
    $sql7 = "SELECT COUNT(id) FROM forum_posts WHERE active = 'yes' AND topic_id = '$topic_id'"; 
    $result7 				= 	mysql_query($sql7);
    $topic_replies			= 	mysql_result($result7,0 );
    
    echo "<table width=\"100%\" border=\"1\" bordercolor=\"993366\" cellspacing=\"0\" cellpadding=\"4\">
    <tr><td align=\"center\" nowrap=\"nowrap\"><font class=\"font\">Status</font></td>
    <td width=\"45%\" align=\"center\" nowrap=\"nowrap\"><font class=\"font\">Topic Title</font></td>
    <td width=\"14%\" align=\"center\" nowrap=\"nowrap\"><font class=\"font\">Topic Starter</font></td>
    <td width=\"7%\" align=\"center\" nowrap=\"nowrap\"><font class=\"font\">Replies</font></td>
    <td width=\"27%\" align=\"center\" nowrap=\"nowrap\"><font class=\"font\">Last Post</font></td>
    </tr><tr><td align=\"center\">";
    
    if ($topic_status == 'open'){
    echo "<img src=\"skin/$skin/images/open.jpg\" alt=\"Topic open\" width=\"20\" height=\"20\">";
    } else {
    echo "<img src=\"skin/$skin/images/closed.jpg\" alt=\"Topic closed\" width=\"20\" height=\"20\">";
    }
    
    echo "<td><a href=\"forum.php?topic=$topic_id\">$topic_title</a></td><td align=\"center\">
    <font class=\"font\">$topic_starter</font></td><td align=\"center\"><font class=\"font\">
    $topic_replies</font></td><td><a href=\"forum.php?topic=$topic_id&page=last\">$last_date - $time</a><br>
    <font class=\"font\">By:</font> <a href='profile.php?name=$last_author'>$last_author</a></td></tr>";
    
    $f++;
    }
    echo "</table>";
    }
    
    include "footer.php";
    
    ?>
    Any suggestions would be great I'm also aware there there probably should be another while in the categorie area, cause it only shows 1 forum in every categorie, but I can fix that later.

    Thanks in advance,

    Borgscan

  2. #2
    SitePoint Evangelist jazztie's Avatar
    Join Date
    Mar 2001
    Location
    the Netherlands
    Posts
    519
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try using single quotes:
    Code:
    $id = $_GET['forum_id'];

  3. #3
    SitePoint Member Borgscan's Avatar
    Join Date
    Sep 2004
    Location
    Australia
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, I thought that might have been the problem too, didn't make any difference.

  4. #4
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    151 Post(s)
    Tagged
    3 Thread(s)
    Hi,
    this section
    PHP Code:
    $sql1 "SELECT * FROM forum_categories WHERE active = 'yes' ORDER BY id"
    $result1 mysql_query($sql1);
    $c=0;
    while (
    $row1 mysql_fetch_array($result1)){

    $cat_id        =    $row1["id"];
    $cat_title    =     $row1["title"]; 
    Might be throwing a spanner in the works as you haven't defined $row1
    ie mysql_fetch_array etc.....

    SpikeZ
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  5. #5
    SitePoint Guru
    Join Date
    Jun 2004
    Location
    Finland
    Posts
    703
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    echo "<td><font class=\"font\"><a href=\"forum.php?idx=forum&id=$forum_id\">$forum_title</a></font>"
    There is no $_GET["forum_id"]. $_GET["id"] is what you're looking for Or change the code to:
    PHP Code:
    echo "<td><font class=\"font\"><a href=\"forum.php?idx=forum&forum_id=$forum_id\">$forum_title</a></font>"

  6. #6
    SitePoint Member Borgscan's Avatar
    Join Date
    Sep 2004
    Location
    Australia
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Sorccu
    PHP Code:
    echo "<td><font class=\"font\"><a href=\"forum.php?idx=forum&id=$forum_id\">$forum_title</a></font>"
    There is no $_GET["forum_id"]. $_GET["id"] is what you're looking for Or change the code to:
    PHP Code:
    echo "<td><font class=\"font\"><a href=\"forum.php?idx=forum&forum_id=$forum_id\">$forum_title</a></font>"
    COOL

    Thankyou Sorccu, it woks now *slaps head* This is most complicated script I've written, I won't make that mistake again. Thankyou so much, and thankyou to all of you for your suggestions - much appreciated.

    Btw, spikeZ could you please elaborate a bit more, I'm not cerntain what you ment. Sorry if I sound a bit thick,


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
  •