Jump to content

[SOLVED] Small problem with code.


eqnastun

Recommended Posts

This code is for a custom MMORPG guild managament system. This little snipet displays all the guild raids 15 per page for maintenance reasons. The problem is. When another page number is clicked the next group of pages does not display. It only will display the first 15 raids on all pages. What am I doing wrong?

if (!$page) {$page=0;}
echo "<center>";
$result = mysql_query("select count(*) from raids",$db);
$myrow = mysql_fetch_row($result);
$pagecount=($myrow[0]/15)+1;
echo "<a href=raid.php?page=0>1</a> ";
$maxpage = intval($pagecount);
$maxpage2 = $maxpage-1;
for ($i==2; $i<($page-9); $i++)
{
$n=$i-1;
if (($i/20)==intval($i/20))
{
	if ($n<>0)
	{
		echo "<a href=raid.php?page=$n>$i</a> ";
	}
}
}
for ($i==($page-9); $i<$pagecount; $i++) 
{
$n=$i-1;
if ($i<($page+11))
{
	if ($n<>0)
	{
		if ($i != $maxpage)
		{
			echo "<a href=raid.php?page=$n>$i</a> ";
		}
	}
}
if ($i>($page+10)) 
{
	if (($i/20)==intval($i/20))
	{
		echo "<a href=raid.php?page=$n>$i</a> ";
	}		
}
}
echo "<a href=raid.php?page=$maxpage2>$maxpage</a> ";
echo "</center>";

$pageid=$page;
$page=$page * 15;
$result = mysql_query("select * from raids order by rdate desc ,id desc limit $page,15",$db);
echo "<br><center><table border=0>\n";
echo "<tr><td></td><td></td><td></tr>\n";
$rowcolour=0;
while ($myrow = mysql_fetch_array($result)) {
  if ($rowcolour==1) {
    $rowcolour=0;
    echo "<tr bgcolor=\"#ffffdd\">";
  } else {
    $rowcolour=1;
    echo "<tr bgcolor=\"#ffffaa\">";
  }
  $id=$myrow["id"];
  echo "<td>";
  if ($myrow["extratime"]) {echo "<b>";}
  if ($myrow["lowattend"]) {echo "<i>";}
  printf("%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>\n",
  $myrow["rname"], $myrow["rdate"], $myrow["rvalue"],$myrow["killvalue"],$myrow["avalue"]);
?>
<form style="margin-bottom:0;" method="post" action=attendance.php>
<input type="hidden" name="id" value="<?php echo $id?>">
<input type="hidden" name="pageid" value="<?php echo $pageid?>">
<input type="image" name="modify" src="edit.gif"></form></td>
<td><form style="margin-bottom:0;" method="post" action="<?php echo $PHP_SELF?>">
<input type="hidden" name="id" value="<?php echo $id?>">
<input type="image" name="delete" src="delete.gif"></form>
<?php
  echo "</td><td><a href=\"javascript:OpenSecure('testing.php?id=",$id,"')\">Modify</a></td></tr>\n";        
}
$realdate=date("Y-m-d");

?>
Thankyou for any help.

Link to comment
Share on other sites

extract($_REQUEST);

 

This is an extremely dangerous solution and a bad habit to get into. register_globals (which essentially does the same thing) hasn't been disabled by default for nothing.

Link to comment
Share on other sites

Next up we have a linking problem. :)

printf("</font></font></br></center>");
echo "<center><a href=\"javascript:OpenSecure('/luterin/postraid.php?id=",$id,"')\">Luterins Custom Cut and Paste!!</a> - ";
echo "<a href=\"javascript:OpenSecure('/luterin/showloot.php?raid=",$id,"')\">Raid Report!</a></center>";

The links appear but load a not found page.

 

This is from a file called attendance.php that is in a folder called admin

There is a subfolder called luterin in the admin folder.

Folders

FR

..admin

....luterin

 

The targetfiles are in the folder and can be accessed. Im pretty sure its a linking issue.

Thanks again

I will be sure to give a donation. I have never seen a forum with help like this.

 

 

 

 

Link to comment
Share on other sites

extract($_REQUEST);

 

This is an extremely dangerous solution and a bad habit to get into. register_globals (which essentially does the same thing) hasn't been disabled by default for nothing.

 

That just doesnt sound good. What is the proper way to fix this with the command you previously listed?

I understand the code basics but I need to complete the tutorials to learn the syntax.

Link to comment
Share on other sites

A bit hard to tell from your directory explanation but / refers to the root directory. Try...

 

echo "<center><a href=\"javascript:OpenSecure('luterin/postraid.php?id=$id')\">Luterins Custom Cut and Paste!!</a> - ";

Link to comment
Share on other sites

That one / was the problem. Thanks

 

 

Page wont load with all of them replaced. Just comes up blank.

if (!$_GET['page']) {$_GET['page']=0;}
echo "<center>";
$result = mysql_query("select count(*) from raids",$db);
$myrow = mysql_fetch_row($result);
$pagecount=($myrow[0]/15)+1;
echo "<a href=raid.php?page=0>1</a> ";
$maxpage = intval($pagecount);
$maxpage2 = $maxpage-1;
for ($i==2; $i<($_GET['page']-9); $i++)
{
$n=$i-1;
if (($i/20)==intval($i/20))
{
	if ($n<>0)
	{
		echo "<a href=raid.php?page=$n>$i</a> ";
	}
}
}
for ($i==($page-9); $i<$pagecount; $i++) 
{
$n=$i-1;
if ($i<($_GET['page']+11))
{
	if ($n<>0)
	{
		if ($i != $maxpage)
		{
			echo "<a href=raid.php?page=$n>$i</a> ";
		}
	}
}
if ($i>($_GET['page']+10)) 
{
	if (($i/20)==intval($i/20))
	{
		echo "<a href=raid.php?page=$n>$i</a> ";
	}		
}
}
echo "<a href=raid.php?page=$maxpage2>$maxpage</a> ";
echo "</center>";
extract($_REQUEST);

$pageid=$_GET['page'];
$_GET['page']_GET['page'] * 15;
$result = mysql_query("select * from raids order by rdate desc ,id desc limit $_GET['page'],15",$db);
echo "<br><center><table border=0>\n";
echo "<tr><td></td><td></td><td></tr>\n";
$rowcolour=0;
while ($myrow = mysql_fetch_array($result)) {
  if ($rowcolour==1) {
    $rowcolour=0;
    echo "<tr bgcolor=\"#ffffdd\">";
  } else {
    $rowcolour=1;
    echo "<tr bgcolor=\"#ffffaa\">";
  }
  $id=$myrow["id"];
  echo "<td>";
  if ($myrow["extratime"]) {echo "<b>";}
  if ($myrow["lowattend"]) {echo "<i>";}
  printf("%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>\n",
  $myrow["rname"], $myrow["rdate"], $myrow["rvalue"],$myrow["killvalue"],$myrow["avalue"]);
?>

Link to comment
Share on other sites

When I press the modify button the id of the raid is not being passes to the testing.php file and the page loads blank

<?php
  echo "</td><td><a href=\"javascript:OpenSecure('testing.php?id=",$id,"')\">Modify</a></td></tr>\n";        
}

Goes to

<?php
# Forsaken order Raid Management Interface.
# Written by Corasik Thule
# July 2002 Earthtime
# Modified by Luterin
# Modified by Gwarg
?>

<?php include("tfolib.php"); ?>
<?php
$db = mysql_connect("127.0.0.1","root","?????");
mysql_select_db("oo7",$db);
?>

<html>
<title>Modify Raid</title>
<body>
<SCRIPT Language="JAVASCRIPT">
function winClose()
{
opener.location.href="raid.php";
window.close()
}
</SCRIPT>


<?php



if ($modify) {
if ($timeraid=="on") {$tmptime=1;} else {$tmptime='NULL';}
if ($ldonraid=="on") {$tmpldon=1;} else {$tmpldon='NULL';}
$flags = ", lowattend=NULL";
if ($lowatt == "on") {$flags = ", lowattend='1'";}
if ($oldraid == "on") {$tmpold=1;} else {$tmpold=0;}
if ($extra == "on") 
{
	$update = mysql_query("update raids set rname='$rname', rdate='$rdate', killvalue='$killvalue', avalue='$avalue', timeraid=$tmptime, ldonraid=$tmpldon, extratime='1', comment='$comment', oldraid='$tmpold' $flags where id=$id");
} 
else 
{
	$update = mysql_query("update raids set rname='$rname', rdate='$rdate', killvalue='$killvalue', avalue='$avalue', timeraid=$tmptime, ldonraid=$tmpldon, extratime=NULL, comment='$comment', oldraid='$tmpold' $flags where id=$id");
}
echo "<script>javascript:winClose()</script>";
exit;
};

$result = mysql_query("select * from raids where id=$id");
$rdetails = mysql_fetch_array($result);

echo $rdetails['rname'];
echo "<table>";
echo "<form method=put action=$PHP_SELF>\n";
echo " <tr>Raid ID - ",$rdetails['id'],"</tr>";
echo " <input type=hidden name=id value=",$id,">\n";
echo " <tr><td>Raid Name:</td><td><input type=Text name=rname value=\"",$rdetails['rname'],"\"><td></tr>\n";
echo " <tr><td>Raid Date:</td><td><input type=Text name=rdate value=\"",$rdetails['rdate'],"\" size=10></td></tr>\n";
echo " <tr><td>Raid Bonus:</td><td><input type=Text name=killvalue value=\"",$rdetails['killvalue'],"\" size=2></td></tr>\n";
echo " <tr><td>Attendance Value:</td><td><input type=Text name=avalue value=\"",$rdetails['avalue'],"\" size=2></td></tr>\n";
echo " <tr><td>Extra Time:</td><td><input type=Checkbox name=extra ",substr('       checked',$rdetails['extratime']*7,7),"></td></tr>\n";
echo " <tr><td>Low Attendance:</td><td><input type=Checkbox name=lowatt ",substr('       checked',$rdetails['lowattend']*7,7),"></td></tr>\n";
//echo " <tr><td>Time Raid:</td><td><input type=Checkbox name=timeraid ",substr('       checked',$rdetails['timeraid']*7,7),"></td></tr>\n";
//echo " <tr><td>LDoN Raid:</td><td><input type=Checkbox name=ldonraid ",substr('       checked',$rdetails['ldonraid']*7,7),"></td></tr>\n";
echo " <tr><td>Old Raid:</td><td><input type=Checkbox name=oldraid ",substr('       checked',$rdetails['oldraid']*7,7),"></td></tr>\n";
//echo " <tr><td>Comment:</td><td><input type=Text name=comment value=\"",$rdetails['comment'],"\"><td></tr>\n";
echo " <tr><td>Comment:</td><td><textarea name=comment wrap=virtual cols=40 rows=3>",$rdetails['comment'],"</textarea><td></tr>\n";
echo " <tr><td><input type=button value=Cancel onClick=winClose()></td><td><input type=Submit name=modify value=Update></td></tr>\n";
echo "</form>\n";
echo "</table>";
exit;

 

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

You need to understand that these variables do not exist anymore. $id needs to be $_GET['id'] in the code you've posted. This is because register globals have been switched off by default in php. They have been off for a long time as they are a security issue. You need to change your code accordingly.

 

Also....

 

if ($modify) {

 

Where is $modify being set? Another mysterious variable?

Link to comment
Share on other sites

I have tried a few versions with IIS6 and I messed something up. So I need to reformat and start over. /bangs head on desk repeatedly. I'll try apache 1.3.x and see if my luck is better. Still clueless as to what version of php will let me use those old global variables.

Link to comment
Share on other sites

If global variables are disabled in the current releases. Using an older version should fix that problem. I wish there was a way to know what version of php the old host was using. If it worked fine on his server why shouldnt it work on mine? I know the code needs to be updated. But I have a highend guild that has been without a DKP system for a month. I have to get it running like it was before I can start to fix it. Please dont take my desperation for rudeness. I just need to get something going before I loose members.

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.