Jump to content

URL problem and GID conflict


Ruko

Recommended Posts

I just implemented a new comment system when one of the testers noticed a bug. When you go to page 2 of the comments, the gid and its information is ignored. And page 2 of the comments is not displayed. If you don't know what im talking about, look at this.

 

http://flash-planet.co.cc/ViewGame.php?gid=93823&pagenum=2

 

How do I fix that.

    <?php

    require_once("mysql.php");

    mysql_select_db("ruko_fp", $con);

   

    $thispage = $_SERVER["REQUEST_URI"];

    $gid = strstr("$thispage","=");

    $gid = substr($gid, 1);



    $result = mysql_query("SELECT * FROM games WHERE gid='$gid'");

    $num_rows = mysql_num_rows($result);

    if($num_rows == 0)

     {

       echo "Sorry! You reached a page or a game that doesn't exist. Please check your URL and try again. If the problem continues, then contact the webmaster or use the report us system.";

     }

    else

     {

       while($row = mysql_fetch_array($result))

        {
	 $imgsrc = $row['imgsrc'];
         $gid = $row['gid'];   
         $gametitle = $row['gametitle'];
         $gamedescription = $row['gamedescription'];
         $gamerating = $row['gamerating'];
         $gamereview = $row['gamereview'];
	 $gamecreator = $row['gamecreator'];
 	 $swf = $row['gameswf'];
 	 $longdes = $row['longdescription'];
 	 $dateadded = $row['dateadded'];
	 $gameurl = $row['gameurl'];

        }

      }

/* Counter goes below these lines

  <!----------------->

  <!----------------->

  <!----------------->

*/

    ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <title>Now Playing - <?=$gametitle;?></title>

    <meta name="description" content="<?=$gamedescription;?>" />

    <meta name="keywords" content="Game, Fun, Flash, <?=$gametitle;?>" />

    <meta name="author" content="Luigi R." />

    <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" />

<link rel="icon" type="image/png" href="images/favi.png" />	

<link rel="stylesheet" href="style.css"  type="text/css" media="screen" />
    

<link rel="stylesheet" href="style.css" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js" type="text/javascript"></script>
<script src="common.js" type="text/javascript"></script>
<script language="javascript">
// Copyright 2006-2007 javascript-array.com

var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
// cancel close timer
mcancelclosetime();

// close old layer
if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

// get new layer and show it
ddmenuitem = document.getElementById(id);
ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
if(closetimer)
{
	window.clearTimeout(closetimer);
	closetimer = null;
}
}

// close layer when click-out
document.onclick = mclose;
</script>

        </head>

<body>

<div class='wrap'>
    
    		    <? include('logo.html') ?>
    
    <? include('announcements.html') ?>

    <? include('categories.html') ?>



<div id="conTop">
  <div id="content">

<h2><?=$gametitle;?></h2>

<div id="playnowbtn"><a href='/PlayGame.php?gid=<?=$gid;?>'><img border="0" src="images/play.png"</a></div>

<br />

<img src='<?=$imgsrc;?>' width="160px" height="125px"  border="1px" />
<br />
<b><?=$gamedescription;?></b>
<lb />
<p>Game Rating: <?=$gamerating;?></p>
<p>Our Reviews: <?=$gamereview;?><p>
<p>Date Added: <?=$dateadded;?></p>
<p>Creator: <?=$gamecreator;?></p>
<p><a href='<?=$gameurl;?>'>Visit Publishers Site</a></p>
<br />
<a href="javascript:toggle('togglelink')">More Info</a>

<div id="togglelink" style="display: none">

<div align="left" class="minfo"><p><?=$longdes;?></p></div>

</div>

<br />
<br />
<br />

<!-- AddThis Button BEGIN -->

<div class="addthis_toolbox addthis_default_style">

<a class="addthis_button_facebook"></a>

<a class="addthis_button_email"></a>

<a class="addthis_button_favorites"></a>

<a class="addthis_button_print"></a>

<span class="addthis_separator">|</span>

<a href="http://www.addthis.com/bookmark.php?v=250&username=xa-4bca9c9a41378345" class="addthis_button_expanded">More</a>

<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4bca9c9a41378345"></script>

<!-- AddThis Button END -->

<br>

<p>Wanna add this game in your website, your blog, or your page? You can! Just copy the code below!</p>

<textarea rows="6" cols="70" class="texta" readonly="readonly"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="400" height="200"> <param name="movie" value="<?=$swf;?>"> <param name="quality" value="high"> <embed src="<?=$swf;?>" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="400" height="200"></embed>

<a href='http://flash-planet.co.cc/ViewGame.php?gid=<?=$gid;?>'>View Game Info</a> <a href='http://flash-planet.co.cc/FullScreen.php?gid=<?=$gid;?>'>Go Full Screen!</a> <a href='<?=$gameurl;?>'><?=$gamecreator?></a>

</object></textarea>
<br>

<b><i>Disclaimer:</b> We do not own or create this game in any way. The creator URL is used so we can give them credit and hard work that they put in this game. If your going to put the game in your website, please do <b><u>NOT</u></b> remove the links below including the creator's URL. If we find that the links are removed, we WILL report you to DMCA and they will shut down your website.</i>
<p><a href='AddComment.php?gid=<?=$gid;?>'>Add Comment</a>
<h4>User Comments</h4>
<?
//This checks to see if there is a page number. If not, it will set it to page 1 
if (!(isset($pagenum))) 
{ 
$pagenum = 1; 
} 

//Here we count the number of results 
//Edit $data to be your query 
$data = mysql_query("SELECT * FROM game_comments WHERE gid='$gid'") or die(mysql_error()); 
$rows = mysql_num_rows($data);

//This is the number of results displayed per page 
$page_rows = 4; 

// We get the comments information


//This tells us the page number of our last page 
$last = ceil($rows/$page_rows); 

//this makes sure the page number isn't below one, or more than our maximum pages 
if ($pagenum < 1) 
{ 
$pagenum = 1; 
} 
elseif ($pagenum > $last) 
{ 
$pagenum = $last; 
} 

//This sets the range to display in our query 
$max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows;

//This is your query again, the same one... the only difference is we add $max into it
$data_p = mysql_query("SELECT * FROM game_comments WHERE gid='$gid' $max") or die(mysql_error()); 


//This is where you display your query results
while($info = mysql_fetch_array( $data_p )) 
{
  $user = $info['user'];
  $title = $info['title'];
  $comments = $info['comment'];
echo "<div class='ComBoxIn'><div class='contentCom'><p>From: <b>$user</b></p>";
echo "<h3>$title</h3>";
echo "<div class='ComBox'><p>$comments</p></div></div></div>";
} 

// This shows the user what page they are on, and the total number of pages
echo " --Page $pagenum of $last-- <p>";

// First we check if we are on page one. If we are then we don't need a link to the previous page or the first page so we do nothing. If we aren't then we generate links to the first page, and to the previous page.
if ($pagenum == 1) 
{
} 
else 
{
echo " <a href='{$_SERVER['PHP_SELF']}?&pagenum=1'> <<-First</a> ";
echo " ";
$previous = $pagenum-1;
echo " <a href='{$_SERVER['PHP_SELF']}?&pagenum=$previous'> <-Previous</a> ";
} 

//just a spacer

//This does the same as above, only checking if we are on the last page, and then generating the Next and Last links
if ($pagenum == $last) 
{
} 
else {
$next = $pagenum+1;
echo " <a href='{$_SERVER['PHP_SELF']}?&pagenum=$next'>Next -></a> ";
echo " ";
echo " <a href='{$_SERVER['PHP_SELF']}?&pagenum=$last'>Last ->></a> ";
} 
?>
  </div>
<? include ('footer.html'); ?>
</div>

</div>
</body>

Link to comment
Share on other sites

Change this

 echo " <a href='{$_SERVER['PHP_SELF']}?&pagenum=$next'>Next -></a> ";
echo " ";
echo " <a href='{$_SERVER['PHP_SELF']}?&pagenum=$last'>Last ->></a> ";

 

To this:

 echo " <a href='{$_SERVER['PHP_SELF']}?gid={$gid}&pagenum={$next}'>Next -></a> ";
echo " ";
echo " <a href='{$_SERVER['PHP_SELF']}?gid={$gid}&pagenum={$last}'>Last ->></a> ";

Link to comment
Share on other sites

Sorry to bump, I just followed your tutorial. And still is causing GID conflict.

    <?php

    require_once("mysql.php");

    mysql_select_db("ruko_fp", $con);

   

    $thispage = $_SERVER["REQUEST_URI"];

    $gid = strstr("$thispage","=");

    $gid = substr($gid, 1);



    $result = mysql_query("SELECT * FROM games WHERE gid='$gid'");

    $num_rows = mysql_num_rows($result);

    if($num_rows == 0)

     {

       echo "Sorry! You reached a page or a game that doesn't exist. Please check your URL and try again. If the problem continues, then contact the webmaster or use the report us system.";

     }

    else

     {

       while($row = mysql_fetch_array($result))

        {
	 $imgsrc = $row['imgsrc'];
         $gid = $row['gid'];   
         $gametitle = $row['gametitle'];
         $gamedescription = $row['gamedescription'];
         $gamerating = $row['gamerating'];
         $gamereview = $row['gamereview'];
	 $gamecreator = $row['gamecreator'];
 	 $swf = $row['gameswf'];
 	 $longdes = $row['longdescription'];
 	 $dateadded = $row['dateadded'];
	 $gameurl = $row['gameurl'];

        }

      }

/* Counter goes below these lines

  <!----------------->

  <!----------------->

  <!----------------->

*/

    ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <title>Now Playing - <?=$gametitle;?></title>

    <meta name="description" content="<?=$gamedescription;?>" />

    <meta name="keywords" content="Game, Fun, Flash, <?=$gametitle;?>" />

    <meta name="author" content="Luigi R." />

    <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" />

<link rel="icon" type="image/png" href="images/favi.png" />	

<link rel="stylesheet" href="style.css"  type="text/css" media="screen" />
    

<link rel="stylesheet" href="style.css" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js" type="text/javascript"></script>
<script src="common.js" type="text/javascript"></script>
<script language="javascript">
// Copyright 2006-2007 javascript-array.com

var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
// cancel close timer
mcancelclosetime();

// close old layer
if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

// get new layer and show it
ddmenuitem = document.getElementById(id);
ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
if(closetimer)
{
	window.clearTimeout(closetimer);
	closetimer = null;
}
}

// close layer when click-out
document.onclick = mclose;
</script>

        </head>

<body>

<div class='wrap'>
    
    		    <? include('logo.html') ?>
    
    <? include('announcements.html') ?>

    <? include('categories.html') ?>



<div id="conTop">
  <div id="content">

<h2><?=$gametitle;?></h2>

<div id="playnowbtn"><a href='/PlayGame.php?gid=<?=$gid;?>'><img border="0" src="images/play.png"</a></div>

<br />

<img src='<?=$imgsrc;?>' width="160px" height="125px"  border="1px" />
<br />
<b><?=$gamedescription;?></b>
<lb />
<p>Game Rating: <?=$gamerating;?></p>
<p>Our Reviews: <?=$gamereview;?><p>
<p>Date Added: <?=$dateadded;?></p>
<p>Creator: <?=$gamecreator;?></p>
<p><a href='<?=$gameurl;?>'>Visit Publishers Site</a></p>
<br />
<a href="javascript:toggle('togglelink')">More Info</a>

<div id="togglelink" style="display: none">

<div align="left" class="minfo"><p><?=$longdes;?></p></div>

</div>

<br />
<br />
<br />

<!-- AddThis Button BEGIN -->

<div class="addthis_toolbox addthis_default_style">

<a class="addthis_button_facebook"></a>

<a class="addthis_button_email"></a>

<a class="addthis_button_favorites"></a>

<a class="addthis_button_print"></a>

<span class="addthis_separator">|</span>

<a href="http://www.addthis.com/bookmark.php?v=250&username=xa-4bca9c9a41378345" class="addthis_button_expanded">More</a>

<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4bca9c9a41378345"></script>

<!-- AddThis Button END -->

<br>

<p>Wanna add this game in your website, your blog, or your page? You can! Just copy the code below!</p>

<textarea rows="6" cols="70" class="texta" readonly="readonly"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="400" height="200"> <param name="movie" value="<?=$swf;?>"> <param name="quality" value="high"> <embed src="<?=$swf;?>" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="400" height="200"></embed>

<a href='http://flash-planet.co.cc/ViewGame.php?gid=<?=$gid;?>'>View Game Info</a> <a href='http://flash-planet.co.cc/FullScreen.php?gid=<?=$gid;?>'>Go Full Screen!</a> <a href='<?=$gameurl;?>'><?=$gamecreator?></a>

</object></textarea>
<br>

<b><i>Disclaimer:</b> We do not own or create this game in any way. The creator URL is used so we can give them credit and hard work that they put in this game. If your going to put the game in your website, please do <b><u>NOT</u></b> remove the links below including the creator's URL. If we find that the links are removed, we WILL report you to DMCA and they will shut down your website.</i>
<p><a href='AddComment.php?gid=<?=$gid;?>'>Add Comment</a>
<h4>User Comments</h4>
<?
// find out how many rows are in the table 
$sql = "SELECT COUNT(*) FROM game_comments WHERE gid='$gid'";
$result = mysql_query($sql, $con) or trigger_error("SQL", E_USER_ERROR);
$r = mysql_fetch_row($result);
$numrows = $r[0];

// number of rows to show per page
$rowsperpage = 5;
// find out total pages
$totalpages = ceil($numrows / $rowsperpage);

// get the current page or set a default
if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) {
   // cast var as int
   $currentpage = (int) $_GET['currentpage'];
} else {
   // default page num
   $currentpage = 1;
} // end if

// if current page is greater than total pages...
if ($currentpage > $totalpages) {
   // set current page to last page
   $currentpage = $totalpages;
} // end if
// if current page is less than first page...
if ($currentpage < 1) {
   // set current page to first page
   $currentpage = 1;
} // end if

// the offset of the list, based on current page 
$offset = ($currentpage - 1) * $rowsperpage;

// get the info from the db 
$sql = "SELECT gid, title FROM game_comments WHERE gid='$gid' LIMIT $offset, $rowsperpage";
$result = mysql_query($sql, $con) or trigger_error("SQL", E_USER_ERROR);

// while there are rows to be fetched...
while ($list = mysql_fetch_assoc($result)) {
   $user = $list['user'];
  $title = $list['title'];
  $comments = $list['comment'];
   // echo data
echo "<div class='ComBoxIn'><div class='contentCom'><p>From: <b>$user</b></p>";
echo "<h3>$title</h3>";
echo "<div class='ComBox'><p>$comments</p></div></div></div>";
} // end while

/******  build the pagination links ******/
// range of num links to show
$range = 3;

// if not on page 1, don't show back links
if ($currentpage > 1) {
   // show << link to go back to page 1
   echo " <a href='{$_SERVER['PHP_SELF']}?gid={$gid}&currentpage=1'><<</a> ";
   // get previous page num
   $prevpage = $currentpage - 1;
   // show < link to go back to 1 page
   echo " <a href='{$_SERVER['PHP_SELF']}?gid={$gid}&currentpage={$prevpage}'><</a> ";
} // end if 

// loop to show links to range of pages around current page
for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {
   // if it's a valid page number...
   if (($x > 0) && ($x <= $totalpages)) {
      // if we're on current page...
      if ($x == $currentpage) {
         // 'highlight' it but don't make a link
         echo " [<b>$x</b>] ";
      // if not current page...
      } else {
         // make it a link
         echo " <a href='{$_SERVER['PHP_SELF']}?gid={$gid}&currentpage=$x'>$x</a> ";
      } // end else
   } // end if 
} // end for
                 
// if not on last page, show forward and last page links        
if ($currentpage != $totalpages) {
   // get next page
   $nextpage = $currentpage + 1;
    // echo forward link for next page 
   echo " <a href='{$_SERVER['PHP_SELF']}?gid={$gid}&currentpage=$nextpage'>></a> ";
   // echo forward link for lastpage
   echo " <a href='{$_SERVER['PHP_SELF']}?gid={$gid}&currentpage=$totalpages'>>></a> ";
} // end if
/****** end build pagination links ******/
/*  $user = $info['user'];
  $title = $info['title'];
  $comments = $info['comment'];
echo "<div class='ComBoxIn'><div class='contentCom'><p>From: <b>$user</b></p>";
echo "<h3>$title</h3>";
echo "<div class='ComBox'><p>$comments</p></div></div></div>";

*/
?>
  </div>
<? include ('footer.html'); ?>
</div>

</div>
</body>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.