Log in

View Full Version : Cant view 2nd page of users [PHP]



Hypertext
21-03-2007, 11:02 PM
heres my code the error is when I try to click users page 2 nothing happens

<?php
include ("includes/header.php");
session_start();
//check if the user is logged in in the 1st place
if(isset($_SESSION['isadmin']))
{
$ID = $_GET['ID'];
$act = $_GET['act'];
if(isset ($ID))
{
if ($act == "delete")
{
$command2 = "Delete from ext_users where ID='$ID'";
mysql_query($command2)
or die($db_error);
print "<center><font face=\"verdana\" color=\"red\" size=\"2\"><b>Success!</b></font></center><p align=\"center\">User deleted!</p>";
print "<p align=\"center\"><a href=\"usercp.php\">Continue</a></p>";
}
else if ($act == "ban")
{
$command = "update ext_users set banned='1' where ID='$ID'";
mysql_query($command)
or die($db_error);
print "<center><font face=\"verdana\" color=\"red\" size=\"2\"><b>Success!</b></font></center><p align=\"center\">User has been banned!</p>";
print "<p align=\"center\"><a href=\"usercp.php\">Continue</a></p>";
}
else if ($act == "unban")
{
$command = "update ext_users set banned='0' where ID='$ID'";
mysql_query($command)
or die($db_error);
print "<center><font face=\"verdana\" color=\"red\" size=\"2\"><b>Success!</b></font></center><p align=\"center\">User has been unbanned!</p>";
print "<p align=\"center\"><a href=\"usercp.php\">Continue</a></p>";
}
else if($act == "makemod")
{
$command = "update ext_users set ismod='1' where ID='$ID'";
mysql_query($command)
or die($db_error);
print "<center><font face=\"verdana\" color=\"red\" size=\"2\"><b>Success!</b></font></center><p align=\"center\">User added as a game mod!</p>";
print "<p align=\"center\"><a href=\"usercp.php\">Continue</a></p>";
}
else if($act == "delmod")
{
$command = "update ext_users set ismod='0' where ID='$ID'";
mysql_query($command)
or die($db_error);
print "<center><font face=\"verdana\" color=\"red\" size=\"2\"><b>Success!</b></font></center><p align=\"center\">User removed as a game mod!</p>";
print "<p align=\"center\"><a href=\"usercp.php\">Continue</a></p>";
}
else
{
print "<center><font face=\"verdana\" color=\"red\" size=\"2\"><b>Error!</b></font></center><p align=\"center\">Please follow the links in the control panel</p>";
print "<p align=\"center\"><a href=\"usercp.php\">Continue</a></p>";
}
}
else
{
print "<table width=\"100%\" cellpadding=\"5px\" align=\"center\" border=\"1\" style=\"border-style:dashed; border-width:thin; border-collapse:collapse;\" cellspacing=\"0px\">";
print "<caption style=\"font-family:Arial, Helvetica, sans-serif; font-weight:bold; font-size:12px\">Users</caption>";
print "<center>All users listed in ABC order</center>";
global $start;
if(!isset($start))
{
$start=0;
}
$command1 = "SELECT * from ext_users order by playername ASC limit $start, 10 ";
$query1 = mysql_query($command1)
or die($db_error);
print "<tr><td>Username</td><td>E-mail</td><td>Level</td><td>Honor</td><td>Gold</td><td>Last Online</td><td>Last IP</td><td>Action</td></tr>";
while($playerinfo = mysql_fetch_array($query1))
{
$time = getdate($playerinfo['ontime']);
if ($playerinfo['ismod'])
{
$lastlink = "<a href=\"usercp.php?ID=".$playerinfo['ID']."&act=delmod\">Remove Mod</a>";
}
else if ($playerinfo['admin'])
{
$lastlink = "<s>Make Mod</s>";
}
else
{
$lastlink = "<a href=\"usercp.php?ID=".$playerinfo['ID']."&act=makemod\">Make Mod</a>";
}
if ($playerinfo['banned'])
{
$link = "<a href=\"usercp.php?ID=".$playerinfo['ID']."&act=unban\">UnBan</a>";
}
else if ($playerinfo['admin'])
{
$link = "<s>Ban</s>";
}
else
{
$link = "<a href=\"usercp.php?ID=".$playerinfo['ID']."&act=ban\">Ban</a>";
}
print "<tr><td>".$playerinfo['playername']."</td><td>".$playerinfo['email']."</td><td>".$playerinfo['lvl']."</td><td>".$playerinfo['honor']."</td><td>".$playerinfo['gold']."</td><td>".$time['mday']." ".$time['month']." ".$time['year']."</td><td>".$playerinfo['lastip']."</td><td><a href=\"usercp.php?ID=".$playerinfo['ID']."&act=delete\">Delete</a> | ".$link." | ".$lastlink."</td></tr>";
}
print "</table>";
$command1 = "SELECT * from ext_users";
$query1 = mysql_query($command1);
$d=0;
$f=0;
$g=1;
print "Page: ";
while($result1 = mysql_fetch_array($query1))
{
if($f%10 == 0)
{
print "[<a href=\"usercp.php?start=$d\">$g</a>] ";
$g++;
}
$d=$d+1;
$f++;
}
$count = mysql_num_rows($query1);
print "<br /><br />No. of users:".$count;
}
}
//if user is not logged in
else
{
print "<script language=\"Javascript\">alert(\"You are not logged in!\");</script>";
print "<meta http-equiv=\"refresh\" content=\"0; url=$path/index.php\" />";
print "<center><a href=\"index.php\">Continue to homepage if browser doesn't redirect you</a></center>";

}
include ("includes/footer.php");
?>

QuickScriptz
21-03-2007, 11:20 PM
Ugh.... it's hideous!!! Your SQL is just plain wrong!!! Below is an example of a properly formatted query....


$result = mysql_query(SELECT * FROM * WHERE * = '*' ORDER BY *) or die(mysql_error());

Notice how firstly I have an or die statement at the end which basically says if there's an error tell me what and where (always good for development phase) and how my query is in CAPS!!

And as for the problem... I have no idea... but I just couldn't let the query format go.. its just so wrong!!

Invent
21-03-2007, 11:20 PM
He didnt code it, so..yeah.

Hypertext
21-03-2007, 11:26 PM
lol i did Invent, i recoded the entire thing thats why alot of things arn't eally working, i hadtocuz everyone flamed me if i didn't.. kkill change sql queries

Agnostic Bear
22-03-2007, 04:08 AM
Ugh.... it's hideous!!! Your SQL is just plain wrong!!! Below is an example of a properly formatted query....


$result = mysql_query(SELECT * FROM * WHERE * = '*' ORDER BY *) or die(mysql_error());

Both yours and his are correctly formatted, here's how I do mine:

$sql = mysql_query("SELECT `blah` FROM `noodles` WHERE `waffles` = 'bagels' AND `bagels` = 'nice' ORDER BY `sugar` DESC");

Notice how firstly I have an or die statement at the end which basically says if there's an error tell me what and where (always good for development phase) and how my query is in CAPS!!
Again, both yours and his queries are correct


And as for the problem... I have no idea... but I just couldn't let the query format go.. its just so wrong!!

The problem is this:
You aren't setting $start properly, you have this:



if(!isset($start))
{
$start=0;
}
Yet you never specify what to do when it's set :)
try this:


if(!isset($_GET["start"]) || !is_numerical($_GET["start"]))
{
$start = "0";
}
else
{
$start = $_GET["start"];
}
That should do ya for.

Hypertext
22-03-2007, 03:55 PM
Lolcoptrs good code +rep
I use a and or die statement test for errors then delete it all, but there were no sql errors, only wierd errors ;P
Also, im looking at some, css etc but i don't want to change every aspect is there any program that ill look through load of files and findand replac certain lines, because you can only go so far without changing html within the php

Tomm
22-03-2007, 04:02 PM
Heres a SQL query to select records 10-20 for example..

SELECT * FROM table WHERE something='something' LIMIT 9,10

Hypertext
22-03-2007, 04:09 PM
argh i thought is_numerical would make it work, it gave it a fatal error. as said apparently is_numerical isn't a defined function..?

Hypertext
22-03-2007, 04:42 PM
erm.. help? been 15 mod + dont -rep me it hs been 15.

Hypertext
22-03-2007, 05:15 PM
been another 15 minutes //

redtom
22-03-2007, 05:33 PM
This is a forum you noob not a chat room, it will take time for people to reply not just 15 mins, just because you can not longer edit does not mean you can post just to bump your topic.

Hypertext
22-03-2007, 07:00 PM
Right anyway i figured it out my parenthasys are wrong, is that how you spell it?

Jamie.
22-03-2007, 07:15 PM
Both yours and his are correctly formatted, here's how I do mine:

$sql = mysql_query("SELECT `blah` FROM `noodles` WHERE `waffles` = 'bagels' AND `bagels` = 'nice' ORDER BY `sugar` DESC");
Again, both yours and his queries are correct



The problem is this:
You aren't setting $start properly, you have this:



if(!isset($start))
{
$start=0;
}
Yet you never specify what to do when it's set :)
try this:


if(!isset($_GET["start"]) || !is_numerical($_GET["start"]))
{
$start = "0";
}
else
{
$start = $_GET["start"];
}
That should do ya for.

Lol nice 1 dan :)

Hypertext
22-03-2007, 07:39 PM
Wierd: I can't post that that post is pointless because my post will be pointlessly insuling a pointless post. ;/ ..erm.. Don't re-post, now because I said it you will, and I bet you will..

Want to hide these adverts? Register an account for free!