eqnastun Posted May 4, 2007 Share Posted May 4, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/49928-solved-small-problem-with-code/ Share on other sites More sharing options...
trq Posted May 4, 2007 Share Posted May 4, 2007 You need to use $_GET['page'] not $page. Quote Link to comment https://forums.phpfreaks.com/topic/49928-solved-small-problem-with-code/#findComment-245034 Share on other sites More sharing options...
eqnastun Posted May 4, 2007 Author Share Posted May 4, 2007 HOLY FAST REPLY Which ones do I change? Quote Link to comment https://forums.phpfreaks.com/topic/49928-solved-small-problem-with-code/#findComment-245039 Share on other sites More sharing options...
jitesh Posted May 4, 2007 Share Posted May 4, 2007 extract($_REQUEST); if (!$page) {$page=0;} echo "<center>"; $result = mysql_query("select count(*) from raids",$db); $myrow = mysql_fetch_row($result); ........... ........... .......... Quote Link to comment https://forums.phpfreaks.com/topic/49928-solved-small-problem-with-code/#findComment-245049 Share on other sites More sharing options...
eqnastun Posted May 4, 2007 Author Share Posted May 4, 2007 That did it. Thanks alot. Its amazing how one small thing can have a huge effect. Now on to the next bug. Quote Link to comment https://forums.phpfreaks.com/topic/49928-solved-small-problem-with-code/#findComment-245079 Share on other sites More sharing options...
trq Posted May 4, 2007 Share Posted May 4, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/49928-solved-small-problem-with-code/#findComment-245086 Share on other sites More sharing options...
eqnastun Posted May 4, 2007 Author Share Posted May 4, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/49928-solved-small-problem-with-code/#findComment-245095 Share on other sites More sharing options...
eqnastun Posted May 4, 2007 Author Share Posted May 4, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/49928-solved-small-problem-with-code/#findComment-245097 Share on other sites More sharing options...
trq Posted May 4, 2007 Share Posted May 4, 2007 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> - "; Quote Link to comment https://forums.phpfreaks.com/topic/49928-solved-small-problem-with-code/#findComment-245099 Share on other sites More sharing options...
trq Posted May 4, 2007 Share Posted May 4, 2007 What is the proper way to fix this with the command you previously listed? Replace all instances of $page with $_GET['page']. Quote Link to comment https://forums.phpfreaks.com/topic/49928-solved-small-problem-with-code/#findComment-245100 Share on other sites More sharing options...
eqnastun Posted May 4, 2007 Author Share Posted May 4, 2007 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"]); ?> Quote Link to comment https://forums.phpfreaks.com/topic/49928-solved-small-problem-with-code/#findComment-245108 Share on other sites More sharing options...
trq Posted May 4, 2007 Share Posted May 4, 2007 Easier still, leave them all as $page and put this at the top. Instead of... if (!$page) {$page=0;} use.... $page = isset($_GET['page']) ? $_GET['page'] : 0; Quote Link to comment https://forums.phpfreaks.com/topic/49928-solved-small-problem-with-code/#findComment-245116 Share on other sites More sharing options...
eqnastun Posted May 4, 2007 Author Share Posted May 4, 2007 There we go working now. Thanks. I'll search for the next problem. Here is a Link to what I am working on. I have pleanty of backups so feel free to check it out http://www.frguild.com/fr/fradmin/raid.php I am just trying to get it working again so any changes wont hurt anything. Quote Link to comment https://forums.phpfreaks.com/topic/49928-solved-small-problem-with-code/#findComment-245121 Share on other sites More sharing options...
eqnastun Posted May 4, 2007 Author Share Posted May 4, 2007 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; Quote Link to comment https://forums.phpfreaks.com/topic/49928-solved-small-problem-with-code/#findComment-245124 Share on other sites More sharing options...
trq Posted May 4, 2007 Share Posted May 4, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/49928-solved-small-problem-with-code/#findComment-245127 Share on other sites More sharing options...
eqnastun Posted May 4, 2007 Author Share Posted May 4, 2007 For a temporary solution while I update the code to work with the latest php. Could I install an olderversion to get my site running? If so what version should I roll back to on my live server? Quote Link to comment https://forums.phpfreaks.com/topic/49928-solved-small-problem-with-code/#findComment-245380 Share on other sites More sharing options...
eqnastun Posted May 5, 2007 Author Share Posted May 5, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/49928-solved-small-problem-with-code/#findComment-246007 Share on other sites More sharing options...
MadTechie Posted May 5, 2007 Share Posted May 5, 2007 Its not a problem with the VERSION, please read the posts over again! Quote Link to comment https://forums.phpfreaks.com/topic/49928-solved-small-problem-with-code/#findComment-246009 Share on other sites More sharing options...
eqnastun Posted May 5, 2007 Author Share Posted May 5, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/49928-solved-small-problem-with-code/#findComment-246010 Share on other sites More sharing options...
MadTechie Posted May 5, 2007 Share Posted May 5, 2007 global variables = secuirty risk, server was probably php 4 (which will not be around for long) your best bet is just to fix it. if you don't have the time then the freelance section may help Quote Link to comment https://forums.phpfreaks.com/topic/49928-solved-small-problem-with-code/#findComment-246012 Share on other sites More sharing options...
eqnastun Posted May 7, 2007 Author Share Posted May 7, 2007 Switched to version 4.1.1 and the pages work great. Now that Its usable I will work on getting the code updated. Thank you for all the help thus far. Quote Link to comment https://forums.phpfreaks.com/topic/49928-solved-small-problem-with-code/#findComment-246942 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.