Racc Posted February 21, 2007 Share Posted February 21, 2007 Basically I have a comment system on posts. When I try opening it I get an error (no thread selected) Which the link should be "http://localhost/index.php?s=comments=1" Now the 1 is '.$url'. I define the URL by using this... if ($result) { while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $url = 'index.php?s=comments='.$row['id']; echo '<p><b>'.$row['title'].'</b><br /> '.$row['sd'].'<br /> Posted by : <b>'.$row['author'].'</b><br /> '.$row['post'].'<br /> <a href="javascript:openComments(\''.$url.'\')"> <a href=\''.$url.'\' title="comments" id="comments"><span>Comments</span></a></a></p>'; So how would I change the index to accomidate that? The index is what defines what the URL is linked to. <?php if ($s == "main") { include("include/news.php"); } else if ($s == "login") { include("include/login.php"); } else if ($s == "logout") { include("include/process.php"); } else if ($s == "register") { include("include/register.php"); } else if ($s == "profile") { include("include/userinfo.php"); } else if ($s == "comments") { include("include/comments.php"); } else if ($s == "admin") { include("include/addnews.php"); } else if ($s == "downloads") { include("include/downloads.php"); } else if ($s == "tutorials") { include("include/tutorials.php"); } else if ($s == "author") { include("include/author.php"); } else if ($s == "links") { include("include/links.php"); } else { echo "<p class=\"error\">The section $s does not exist!</p>\n"; } ?> Thanks, I'm sure it's really easy, i'm beating myself up over this. Link to comment https://forums.phpfreaks.com/topic/39441-solved-help-please-s/ Share on other sites More sharing options...
monk.e.boy Posted February 21, 2007 Share Posted February 21, 2007 have you tried a different url: http://www.mysite.com/index.php?s=comments&page=2 then in the code you can access the two variables: $s = $_GET['comments']; $page = $_GET['page']; echo $s; // prints comments echo $page; // prints 2 does that help? monk.e.boy Link to comment https://forums.phpfreaks.com/topic/39441-solved-help-please-s/#findComment-190351 Share on other sites More sharing options...
Racc Posted February 24, 2007 Author Share Posted February 24, 2007 have you tried a different url: http://www.mysite.com/index.php?s=comments&page=2 then in the code you can access the two variables: $s = $_GET['comments']; $page = $_GET['page']; echo $s; // prints comments echo $page; // prints 2 does that help? monk.e.boy I'm pretty new to php/mysql, could you explain abit? Link to comment https://forums.phpfreaks.com/topic/39441-solved-help-please-s/#findComment-192829 Share on other sites More sharing options...
Yesideez Posted February 24, 2007 Share Posted February 24, 2007 if ($result) { while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $url = 'index.php?comments='.$row['id']; echo '<p><b>'.$row['title'].'</b><br />'.$row['sd'].'<br /> Posted by : <b>'.$row['author'].'</b><br />'.$row['post'].'<br /> <a href="javascript:openComments(\''.$url.'\')"> <a href=\''.$url.'\' title="comments" id="comments"><span>Comments</span></a></a></p>'; I've removed the "s=" from the command line. ?s=comment= is invalid syntax. If you want s added as well, do you have a variable for it? Link to comment https://forums.phpfreaks.com/topic/39441-solved-help-please-s/#findComment-192837 Share on other sites More sharing options...
xyn Posted February 24, 2007 Share Posted February 24, 2007 This should work... Note: make sure you change the commentid=ID to suit the coding in the Comments page ie, the SQL Syntax would be $_GET['commentid']; if ($result) { while ($row = mysql_fetch_array($result)) { $url = "index.php?s=comments&commentid=".$row['id']; echo "<p><b>".$row['title']."</b><br /> ".$row['sd']."<br /> Posted by : <b>".$row['author']."</b><br /> ".$row['post']."<br /> <a href=\"javascript:openComments('".$url."')\"> <a href=\"".$url."\" title=\"comments\" id=\"comments\"><span>Comments</span></a></a></p>"; Link to comment https://forums.phpfreaks.com/topic/39441-solved-help-please-s/#findComment-192845 Share on other sites More sharing options...
Archadian Posted February 24, 2007 Share Posted February 24, 2007 http://localhost/index.php?s=comments=1 $s = $_GET['comments']; $page = $_GET['page']; in your URL you need to have the "page" variable also because you are trying to get it from the URL with $_GET['page'], like this: http://localhost/index.php?s=comments&page=1 Link to comment https://forums.phpfreaks.com/topic/39441-solved-help-please-s/#findComment-192889 Share on other sites More sharing options...
Racc Posted February 25, 2007 Author Share Posted February 25, 2007 This should work... Note: make sure you change the commentid=ID to suit the coding in the Comments page ie, the SQL Syntax would be $_GET['commentid']; if ($result) { while ($row = mysql_fetch_array($result)) { $url = "index.php?s=comments&commentid=".$row['id']; echo "<p><b>".$row['title']."</b><br /> ".$row['sd']."<br /> Posted by : <b>".$row['author']."</b><br /> ".$row['post']."<br /> <a href=\"javascript:openComments('".$url."')\"> <a href=\"".$url."\" title=\"comments\" id=\"comments\"><span>Comments</span></a></a></p>"; Thanks! More importantly, thank you everyone. Link to comment https://forums.phpfreaks.com/topic/39441-solved-help-please-s/#findComment-193679 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.