Jump to content

Recommended Posts

Posted

$result = mysql_query("SELECT * FROM `characters` ORDER BY `totalKills` DESC LIMIT 0 , 100 ");

You should do :

$result = mysql_query("SELECT `name`, `level`, `totalKills`, `totalHonorPoints` FROM `characters` ORDER BY `totalKills` DESC LIMIT 0 , 100 ");

  • Replies 171
  • Created
  • Last Reply

Top Posters In This Topic

Posted
$result = mysql_query("SELECT * FROM `characters` ORDER BY `totalKills` DESC LIMIT 0 , 100 ");

You should do :

$result = mysql_query("SELECT `name`, `level`, `totalKills`, `totalHonorPoints` FROM `characters` ORDER BY `totalKills` DESC LIMIT 0 , 100 ");

i merely made it work, i didn't intend to actually make it safe and efficient by only retrieving the required data....but thanks for sharing thoughts anyway...i'll change it

changed version:

<?php
$reading = @fopen('config.php', 'r');
if ($reading)
   include ("config.php");
else
{
   $user = "root";
   $host = "localhost";
   $port = "3306";
   $pass = "mangos";
   $mangoscharacters = "characters";
}
$host = $host.":".$port;
$characters = mysql_connect("$host", "$user", "$pass") or die('Connection Failed');
mysql_selectdb ("$mangoscharacters") or die('Cannot connect to Characters Database');
$result = mysql_query("SELECT `name`, `level`, `totalKills`, `totalHonorPoints` FROM `characters` ORDER BY `totalKills` DESC LIMIT 0 , 100 ");
?>
<font color=#000000>
   <table align=center cellpadding="0" cellspacing="0"  border="1" width=100%>
   <thead>
       <td width="4%"><center>Nº</center></td>
       <td width="16%"><center>Character Name</center></td>
       <td width="4%"><center>level</center></td>
       <td width="5%"><center>Honor</center></td>
       <td width="4%"><center>Kills</center></td>
   </thead>
   <tbody>

<?php
while($rows = mysql_fetch_object($result)) 
{ 
   $i++; 
   $name = $rows->name; 
   $level = $rows->level;  
   $Total_Kills = $rows->totalKills;
   $Total_Honor = $rows->totalHonorPoints;

   echo "
       <tr>
       <td><center>",$i,"</center></td>
       <td>[i]",$name,"[/i]</td>
       <td><center>",$level,"</center></td>
       <td><center>",$Total_Honor,"</center></td>
   <td><center>",$Total_Kills,"</center></td>
       </tr>";
}
mysql_close($characters);
?>

  • 2 weeks later...
Posted
Heya

who can help me with a GM online check ( online check, if online a gm on my server )

regards

Betaman

The way I think it can be done (I'm no script genius), is to add a second filter to this line:-

$result = mysql_query ("SELECT name, race, class, level, map, gender FROM characters WHERE online = 1");

Something like $result = mysql_query ("SELECT name, race, class, level, map, gender FROM characters WHERE online = 1 AND Realmd/Tables/Account GMlevel >0");

Hopefully someone will...um..adjust my attempt :D

Posted
Heya

who can help me with a GM online check ( online check, if online a gm on my server )

regards

Betaman

The way I think it can be done (I'm no script genius), is to add a second filter to this line:-

$result = mysql_query ("SELECT name, race, class, level, map, gender FROM characters WHERE online = 1");

Something like $result = mysql_query ("SELECT name, race, class, level, map, gender FROM characters WHERE online = 1 AND Realmd/Tables/Account GMlevel >0");

Hopefully someone will...um..adjust my attempt :D

think this should work:

.....

$result = mysql_query ("SELECT name, race, class, level, map, gender FROM characters WHERE online = 1[/b] and accid in([color=blue]select accid from realmd where gmlevel >0)[/color];

not tested

it has nothing todo with PHP just SQL :)

Posted

Hi, i have a problem..

I have created the next script for a staff page.. where it should show all the staff names.

the script look's like this.

                                  <?PHP
require_once ( 'config.php');

mysql_connect ("$host","$user","$pass");
mysql_select_db ("$mangoscharacters");

$result = mysql_query ("SELECT name FROM characters WHERE account IN (SELECT id FROM $mangosrealm.account WHERE gmlevel > 3 ORDER BY NAME)");
{
 $row = mysql_fetch_array($result);
 $t_name = $row['name'];
   echo "[b]<span style='color: #B00000'>$t_name[/b]</span>";
}

?>   

But i have a problem. if two staff persons have the same level ( ex 4)

the script will show just one..

How i can make ti show all?

I mean if 3 players have gm level 4 to show all 3 players.. not just one..

thanks.

Posted
level 4 to show all 3 players.. not just on

the problem is you show 1 player not 1 per gm level

you haven't any loop in the script...

Mfg

try this:

                                  <?PHP
require_once ( 'config.php');

mysql_connect ("$host","$user","$pass");
mysql_select_db ("$mangoscharacters");

$result = mysql_query ("SELECT name FROM characters WHERE account IN (SELECT id FROM $mangosrealm.account WHERE gmlevel > 3 ORDER BY NAME)");

while( $row = mysql_fetch_array($result))
{
 $t_name = $row['name'];
   echo "[b]<span style='color: #B00000'>$t_name[/b]</span>";
}

?>   

Posted

thanks

But i found another problem.

The password recover script dosen't rest the password.

You get the new password. but you cannot log with it..the old password still works..

The script i use

 <?php
/*
Very important! You need to run SQL update!
ALTER TABLE `account` ADD `reset_password` VARCHAR( 50 ) NOT NULL;
*/
/*Config*/
$realmd = array(
'db_host'=> 'localhost', //ip of db realm
'db_username' => 'username',//realm user
'db_password' => 'password',//realm password
'db_name'=> 'realmd',//realm db name
);
$config = array(
'path_to_thisfile' => 'link', // Example: [url]http://mysite.com/lol/ownage/wow/[/url]
'email_from' => 'email', // Who should the email be sent from ?
'email_subject' => 'Pass recover ', // Subject of the mail ??
);



function sha_password($user,$pass){
$user = strtoupper($user);
$pass = strtoupper($pass);

return SHA1($user.':'.$pass);
}
function random_string($counts){
$str = "abcdefghijklmnopqrstuvwxyz";//Count 0-25
for($i=0;$i<$counts;$i++){
if ($o == 1){
$output .= rand(0,9);
$o = 0;
}else{
$o++;
$output .= $str[rand(0,25)];
}

}
return $output;
}


$realmd_bc_new_connect = mysql_connect($realmd[db_host],$realmd[db_username],$realmd[db_password]);
$selectdb = mysql_select_db($realmd[db_name],$realmd_bc_new_connect);

if ($_GET[h] && $_GET[h] != '' && $_GET[h] != '0'){
$output_random_pass = random_string(10);
$query = mysql_query("SELECT username FROM `account` WHERE reset_password='$_GET[h]'");
$res = mysql_fetch_array($query);
if (mysql_num_rows($query) == 1){
echo "Hi $res[username], Your password is: $output_random_pass. Please change your password fast as possible.";
$pass_hash = sha_password($res[username],$output_random_pass);
mysql_query("UPDATE `account` SET sha_pass_hash='$pass_hash' WHERE reset_password='$_GET[h]'");
mysql_query("UPDATE `account` SET reset_password='' WHERE username='$res[username]'");
}else{
echo "Error.";
}

}else{
?>

<?php
//this is where user fill in and send by email
if ($_POST[password_takeback]){
$check_security = mysql_query("SELECT id FROM `account` WHERE username='$_POST[username]' AND email='$_POST[email]'");
if (isset($_POST['username']) && isset($_POST['email']) && mysql_num_rows($check_security) == 1){
$rand = random_string(40);
mysql_query("UPDATE `account` SET reset_password='$rand' WHERE username='$_POST[username]'");
$to = $_POST["email"];
$from = "From: $config[email_from]";
$subject = $config[email_subject];
$message= "Hi $_POST[username], you have submitted a password recovery on our site. IF YOU DIDNT SUBMIT A PASSWORD REQUEST JUST DELETE THIS MAIL!. Please follow this link to complete the operation: $config[path_to_thisfile]?h=$rand";
mail($to, $subject, $message, $from); // This work if you have configured your php.ini file to send email, !on linux its default.
echo "An Email has been sent to you, please follow the email to complete the process.";
}else{
echo "Incorrect details, Please be sure that you submitted right Email and Username to your account";
}
}else{
?>
<form action="<?php echo $_SERVER[php_SELF]; ?>" method="POST">


Your Email:
 <input type="text" name="email">
   </p>


Your Username:
 <input type="text" name="username">
 </p>




   <input type="submit" name="password_takeback" value="Recover Password">
 </p>
</form>
<?php
}
}// End GET
?>

Posted

Change

while( $row = mysql_fetch_array($result))
{
 $t_name = $row['name'];
   echo "[b]<span style='color: #B00000'>$t_name[/b]</span>";
}

to

while( $row = mysql_fetch_array($result))
{
 $t_name = $row['name'];
   echo "[b]<span style='color: #B00000'>$t_name[/b]</span>
";
}

Posted
thanks but i solved that one.. i used:

echo "

[b]<span style='color: #B00000'>$t_name[/b]</span></p>";

Now i have a another problem with password recovery. please check edited post.

so at which point does it stop working?

1. Enter name and email adres

2. Submit

3. Process the form, insert a random integer into the reset_password field of that account

4. Send email with a link with which you can receive the pass after the change

-- User action: open email and click link

5. Open the link, get functions retrieve the random integer from the link

6. the random integer gets queried, this results in finding the accountname again

7. field sha_pass_hash gets set to the contains of reset_pass

8. reset_pass gets emptied (basically deactivating the link in the email)

Posted

ok so i use

<?php
/*
Very important! You need to run SQL update!
ALTER TABLE `account` ADD `reset_password` VARCHAR( 50 ) NOT NULL;
*/
/*Config*/
$realmd = array(
'db_host'=> 'localhost', //ip of db realm
'db_username' => 'username',//realm user
'db_password' => 'password',//realm password
'db_name'=> 'realmd',//realm db name
);
$config = array(
'path_to_thisfile' => 'link', // Example: [url]http://mysite.com/lol/ownage/wow/[/url]
'email_from' => 'email', // Who should the email be sent from ?
'email_subject' => 'Pass recover ', // Subject of the mail ??
);



function sha_password($user,$pass){
$user = strtoupper($user);
$pass = strtoupper($pass);

return SHA1($user.':'.$pass);
}
function random_string($counts){
$str = "abcdefghijklmnopqrstuvwxyz";//Count 0-25
for($i=0;$i<$counts;$i++){
if ($o == 1){
$output .= rand(0,9);
$o = 0;
}else{
$o++;
$output .= $str[rand(0,25)];
}

}
return $output;
}


$realmd_bc_new_connect = mysql_connect($realmd[db_host],$realmd[db_username],$realmd[db_password]);
$selectdb = mysql_select_db($realmd[db_name],$realmd_bc_new_connect);

if ($_GET[h] && $_GET[h] != '' && $_GET[h] != '0'){
$output_random_pass = random_string(10);
$query = mysql_query("SELECT username FROM `account` WHERE reset_password='$_GET[h]'");
$res = mysql_fetch_array($query);
if (mysql_num_rows($query) == 1){
echo "Hi $res[username], Your password is: $output_random_pass. Please change your password fast as possible.";
$pass_hash = sha_password($res[username],$output_random_pass);
mysql_query("UPDATE `account` SET sha_pass_hash='$pass_hash' WHERE reset_password='$_GET[h]'");
mysql_query("UPDATE `account` SET reset_password='' WHERE username='$res[username]'");
}else{
echo "Error.";
}

}else{
?>

<?php
//this is where user fill in and send by email
if ($_POST[password_takeback]){
$check_security = mysql_query("SELECT id FROM `account` WHERE username='$_POST[username]' AND email='$_POST[email]'");
if (isset($_POST['username']) && isset($_POST['email']) && mysql_num_rows($check_security) == 1){
$rand = random_string(40);
mysql_query("UPDATE `account` SET reset_password='$rand' WHERE username='$_POST[username]'");
$to = $_POST["email"];
$from = "From: $config[email_from]";
$subject = $config[email_subject];
$message= "Hi $_POST[username], you have submitted a password recovery on our site. IF YOU DIDNT SUBMIT A PASSWORD REQUEST JUST DELETE THIS MAIL!. Please follow this link to complete the operation: $config[path_to_thisfile]?h=$rand";
mail($to, $subject, $message, $from); // This work if you have configured your php.ini file to send email, !on linux its default.
echo "An Email has been sent to you, please follow the email to complete the process.";
}else{
echo "Incorrect details, Please be sure that you submitted right Email and Username to your account";
}
}else{
?>
<form action="<?php echo $_SERVER[php_SELF]; ?>" method="POST">


Your Email:
 <input type="text" name="email">
   </p>


Your Username:
 <input type="text" name="username">
 </p>




   <input type="submit" name="password_takeback" value="Recover Password">
 </p>
</form>
<?php
}
}// End GET
?>

after i get the mail, i acces the link. and it says.. your new password is Mangos. Please change your password as soon as possible.

(mangos is an example)

When i try to login with the pass mangos. it dosent work. it says incorect password.

when i try to login with the old pass, it works.

so somewhere in the query of mysql something is bad.

the new password dosent change the old one..

so the old one remains.

Posted
Heya

who can help me with a GM online check ( online check, if online a gm on my server )

regards

Betaman

The way I think it can be done (I'm no script genius), is to add a second filter to this line:-

$result = mysql_query ("SELECT name, race, class, level, map, gender FROM characters WHERE online = 1");

Something like $result = mysql_query ("SELECT name, race, class, level, map, gender FROM characters WHERE online = 1 AND Realmd/Tables/Account GMlevel >0");

Hopefully someone will...um..adjust my attempt :D

think this should work:

.....

$result = mysql_query ("SELECT name, race, class, level, map, gender FROM characters WHERE online = 1[/b] and accid in([color=blue]select accid from realmd where gmlevel >0)[/color];

not tested

it has nothing todo with PHP just SQL :)

not working, and the another tips dont work too ( i need only a number, how many gms are online or not )

Posted

The way I think it can be done (I'm no script genius), is to add a second filter to this line:-

$result = mysql_query ("SELECT name, race, class, level, map, gender FROM characters WHERE online = 1");

Something like $result = mysql_query ("SELECT name, race, class, level, map, gender FROM characters WHERE online = 1 AND Realmd/Tables/Account GMlevel >0");

Hopefully someone will...um..adjust my attempt :D

think this should work:

.....

$result = mysql_query ("SELECT name, race, class, level, map, gender FROM characters WHERE online = 1[/b] and accid in([color=blue]select accid from realmd where gmlevel >0)[/color];

not tested

it has nothing todo with PHP just SQL :)

not working, and the another tips dont work too ( i need only a number, how many gms are online or not )

i'm not sure of the columns/table spelling, so pls verify for using this sql statement in your PHP

.....

$result = mysql_query ("SELECT count(*) FROM characters WHERE online = 1[/b] and account in([color=blue]select id from realmd.account where gmlevel >0)[/color];

Posted

why u use colors in your sql

SELECT count(*) FROM characters WHERE online = 1[/b] and account in([color=blue]select id from realmd.account where gmlevel >0)[/color];

100 % not working

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[/b] and account in([color=blue]select id from realmd.account where gmlevel >0)[' at line 1

Posted

i just changed an existing statement and for the old forum it wouldn't interefer :-)

SELECT count(*) FROM characters WHERE online = 1 and account in(select id from realmd.account where gmlevel >0);

Posted
yeah that works, now a full php script :)

<?PHP
require_once ( 'config.php');

mysql_connect ("$host","$user","$pass");
mysql_select_db ("$mangoscharacters");

$result = mysql_query (" insert here the working SQL Query ");

$row = mysql_fetch_array($result)
print_r($row);

?>

you can change the print_r($row) with something like echo "GMs online: ".$row['count'] ; // 'count' is the column name!!!!

Posted

yeah thx but not working

$result = mysql_query ("SELECT count(*) FROM characters WHERE online = 1 AND account IN(SELECT id FROM realmd.account WHERE gmlevel >0");

$row = mysql_fetch_array($result)
echo "GMs online: ".$row;

Parse error: syntax error, unexpected T_ECHO

Posted

$result = mysql_query ("SELECT count(*) FROM characters WHERE online = 1 AND account IN (SELECT id FROM realmd.account WHERE gmlevel >0");

is missing a parenthesis

$result = mysql_query ("SELECT count(*) FROM characters WHERE online = 1 AND account IN (SELECT id FROM realmd.account WHERE gmlevel >0)");

Posted

Hi guys. i have a problem.

Players online script show something like this

Name lvl className lvl className lvl class.

how i can make it to show like this

Name lvl class

Name lvl class

Name lvl class

Here is an example on how it looks atm

Admin 80 RogueGamemaster 80 MageModerator 80 Warlock

If i want to look like this :

Admin 80 Rogue

GameMaster 80 Mage

Moderator 80 Warlock

The script i use :

                                    <?PHP                            

require_once ('config.php');

mysql_connect ("$host","$user","$pass");
mysql_select_db ("$mangoscharacters");

$result = mysql_query ("SELECT name, race, class, level, gender FROM characters WHERE online = 1");
$num_online = mysql_num_rows($result);

$class = array(1=>"[img=img/class/1.gif]",2=>"[img=img/class/2.gif]",3=>"[img=img/class/3.gif]",4=>"[img=img/class/4.gif]",5=>"[img=img/class/5.gif]",6=>"[img=img/class/6.gif]",

7=>"[img=img/class/7.gif]",8=>"[img=img/class/8.gif]",9=>"[img=img/class/9.gif]",11=>"[img=img/class/11.gif]");
$race = array(1=>"[img=img/race/1-0.gif]",2=>"[img=img/race/2-0.gif]",3=>"[img=img/race/3-0.gif]",4=>"[img=img/race/4-0.gif]",5=>"[img=img/race/5-0.gif]",6=>"[img=img/race/6-0.gif]",7=>"[img=img/race/7-0.gif]",8=>"[img=img/race/8-0.gif]",10=>"[img=img/race/10-0.gif]",11=>"[img=img/race/11-0.gif]");
$gender = array(0=>"Male",1=>"Female");

if($num_online < 1) {
 echo "<tr><td colspan='4' align='center'>No Players Online!</td></tr>";
}

for($i=0; $i<$num_online; $i++) {
 $row = mysql_fetch_array($result);
 $t_name = $row['name'];
 $t_race = $row['race'];
 $t_class = $row['class'];
 $t_lvl = $row['level'];
 $t_gender = $row['gender'];
 echo "$t_name ";
 echo "  $race[$t_race]";
 echo "  $class[$t_class]";
 echo "  $t_lvl";
 echo "  $gender[$t_gender]";
}

?>

Posted

I have solved the problem.. the script is here.

                                    <?PHP                            

require_once ('config.php');

mysql_connect ("$host","$user","$pass");
mysql_select_db ("$mangoscharacters");

$result = mysql_query ("SELECT name, race, class, level, gender FROM characters WHERE online = 1");
$num_online = mysql_num_rows($result);

$class = array(1=>"[img=img/class/1.gif]",2=>"[img=img/class/2.gif]",3=>"[img=img/class/3.gif]",4=>"[img=img/class/4.gif]",5=>"[img=img/class/5.gif]",6=>"[img=img/class/6.gif]",

7=>"[img=img/class/7.gif]",8=>"[img=img/class/8.gif]",9=>"[img=img/class/9.gif]",11=>"[img=img/class/11.gif]");
$race = array(1=>"[img=img/race/1-0.gif]",2=>"[img=img/race/2-0.gif]",3=>"[img=img/race/3-0.gif]",4=>"[img=img/race/4-0.gif]",5=>"[img=img/race/5-0.gif]",6=>"[img=img/race/6-0.gif]",7=>"[img=img/race/7-0.gif]",8=>"[img=img/race/8-0.gif]",10=>"[img=img/race/10-0.gif]",11=>"[img=img/race/11-0.gif]");
$gender = array(0=>"Male",1=>"Female");

if($num_online < 1) {
 echo "<tr><td colspan='4' align='center'>No Players Online!</td></tr>";
}

for($i=0; $i<$num_online; $i++) {
 $row = mysql_fetch_array($result);
 $t_name = $row['name'];
 $t_race = $row['race'];
 $t_class = $row['class'];
 $t_lvl = $row['level'];
 $t_gender = $row['gender'];
 echo "

$t_name";
 echo "  $race[$t_race]";
 echo "  $class[$t_class]";
 echo "  $t_lvl";
 echo "  $gender[$t_gender]</p>";
}

?>

* I have added

</p>

×
×
  • 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. Privacy Policy Terms of Use