Jump to content

|PHP| Interesting Scripts for your Website


Recommended Posts

Thanks dude. I am again enlightened :D

Still have a problem though.

I now have two files.

index.php with this inside:-

<?

      // Include the configuration file (definitions of username, password, host, ecc) into the index.php file.
      require_once ('config.php');

      // Connect to the database and sets a resource link to variable "$conn".
      $conn = mysql_connect($host, $user, $pass) or die('Connection failed: ' . mysql_error());

      // Selects the database such as "realmd", "mangos", ecc.
      mysql_select_db($mangoscharacters, $conn) or die('Select DB failed: ' . mysql_error());

      // Executes the string query on resource link "$conn".
      $result = mysql_query("SELECT Count(Online) FROM `characters` WHERE `online` = 1", $conn);

      // Splits the first row into an associative array.
      $row = mysql_fetch_array($result);

      // Print to screen a value of field "count(online)".
      echo $row["Count(Online)"];

?>

As you suggested and made a config.php with this inside:-

<?php 
$ip = "earthwalker.servegame.com";
$port = "3306";
$host = "localhost";
$user = "root";
$pass = "***"; 
$mangoscharacters = "characters";
$mangosrealm = "realmd";
$cod = 'utf8';
?>

Both files inside xampp/htdocs/erk

so I do http://my-no-ip/erk/ and just get a blank page :(

To see if the page could be seen from the outside, I just made an index.html with the words 'eek' lol.

I went to that page http://my-no-ip/erk/index.html and it printed 'eek' so I know that folder is seen.

I do have a standard registration page in another folder and that loads fine too.

Any clues as to what I'm doing wrong?

Link to comment
Share on other sites

  • Replies 171
  • Created
  • Last Reply

Top Posters In This Topic

Original Code by Kpacavcheg

* Show Online PPL (Nick, Race, Class, Level, Gender).

<center><table border="0" width="50%">
 <tr>
  <td>[b]Nick:    [/b]</td>
  <td>[b]Race:    [/b]</td>
  <td>[b]Class:    [/b]</td>
  <td>[b]Level:    [/b]</td>
  <td>[b]Gender:    [/b]</td>
 </tr>
<?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=>"Warrior",2=>"Paladin",3=>"Hunter",4=>"Rogue",5=>"Priest",6=>"Death 

Knight",7=>"Shaman",8=>"Mage",9=>"Brujo",11=>"Druid");
$race = array(1=>"Human",2=>"Orc",3=>"Dwarf",4=>"Night Elf",5=>"Undead",6=>"Tauren",7=>"Gnome",8=>"Troll",10=>"Blood Elf",11=>"Draenei");
$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 "<tr>
   <td>[b]$t_name[/b]</td>";
 echo "<td>[b]$race[$t_race][/b]</td>";
 echo "<td>[b]$class[$t_class][/b]</td>";
 echo "<td>[b]$t_lvl[/b]</td>";
 echo "<td>[b]$gender[$t_gender][/b]</td>
   </tr>";
}

?>

Altered this script as found a couple of typos and lack of ? in part of it.

Link to comment
Share on other sites

I've been fiddling as best I can with the above script to add the location of the toon.

* Show Online PPL (Nick, Race, Class, Level, map, Gender).



<center><table border="1" width="50%">
 <tr>
  <td>[b]Nick:    [/b]</td>
  <td>[b]Race:    [/b]</td>
  <td>[b]Class:    [/b]</td>
  <td>[b]Level:    [/b]</td>
  <td>[b]Location:        [/b]</td>
  <td>[b]Gender:    [/b]</td>
 </tr>
<?php

require_once ( 'config.php');

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

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

$class = array(1=>"Warrior",2=>"Paladin",3=>"Hunter",4=>"Rogue",5=>"Priest",6=>"Death 

Knight",7=>"Shaman",8=>"Mage",9=>"Warlock",11=>"Druid");
$race = array(1=>"Human",2=>"Orc",3=>"Dwarf",4=>"Night Elf",5=>"Undead",6=>"Tauren",7=>"Gnome",8=>"Troll",10=>"Blood Elf",11=>"Draenei");
$map = array(0=>"Eastern Kingdoms",1=>"Kalimdor",33=>"Shadowfang Keep",34=>"Stormwind Stockade",35=>"Stormwind Prison",36=>"Deadmines",43=>"Wailing Caverns",44=>"Monastery",47=>"Razorfen Kraul",48=>"Blackfathom",70=>"Uldaman",90=>"Gnomeragon",109=>"Sunken Temple",129=>"Razorfen Downs",169=>"Emerald Dream",189=>"Monastery",209=>"Tanaris",229=>"Black Rock Spire",230=>"Black Rock Depths",249=>"Onyxia Lair",269=>"Caverns Of Time",289=>"School of Necromancy",309=>"Zulgurub",329=>"Stratholme",349=>"Mauradon",369=>"Deeprun Tram",389=>"Orgrimmar",409=>"MoltenCore",429=>"DireMaul",469=>"Blackwing Lair",509=>"AhnQiraj",530=>"Dalaran",531=>"AhnQiraj Temple",532=>"Karazahn",533=>"Stratholme",534=>"Hyjal Past",540=>"Hellfire Military",542=>"Hellfire Demon",543=>"Hellfire Rampart",544=>"Hellfire Raid",545=>"Coilfang Pumping",546=>"Coilfang Marsh",547=>"Coilfang Draenei",548=>"Coilfang Raid",550=>"Tempest Keep Raid",552=>"Tempest Keep Arcane",553=>"Tempest Keep Atrium",554=>"Tempest Keep Factory",555=>"Auchindoun Shadow",556=>"Auchindoun Demon",557=>"Auchindoun Ethereal",558=>"Auchindoun Draenei",560=>"Hillsbrad Past",562=>"Blades Edge Arena",564=>"Black Temple",565=>"Gruuls Lair",566=>"Netherstorm BG",568=>"ZulAman",571=>"Northrend",574=>"Valgarde 70",575=>"Utgarde Pinnacle",576=>"Nexus 70",578=>"Nexus 80",580=>"Sunwell Plateau",595=>"Stratholme COT",598=>"Sunwell 5",599=>"Ulduar 70",600=>"Drak Theron Keep",602=>"Ulduar 80",603=>"Ulduar Raid",604=>"GunDrak",607=>"Northrend BG",608=>"Violet Hold",609=>"Ebon Hold",615=>"The Obsidian Sanctum",616=>"The Eye of Eternity",617=>"Dalaran Sewers",618=>"The Ring of Valor",619=>"Ahn'kahet: The Old Kingdom",624=>"Vault of Archavon",628=>"Isle of Conquest",631=>"Icecrown Citadel Raid",632=>"Forge of Souls",649=>"Argent Tournament Raid",650=>"Argent Tournament Dungeon",658=>"Pit Of Saron",668=>"Halls of Reflection",723=>"Stormwind",724=>"The Ruby Sanctum");
$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_map = $row['map'];
$t_gender = $row['gender'];
echo "<tr>
<td>[b]$t_name[/b]</td>";
echo "<td>[b]$race[$t_race][/b]</td>";
echo "<td>[b]$class[$t_class][/b]</td>";
echo "<td>[b]$t_lvl[/b]</td>";
echo "<td>[b]$map[$t_map][/b]</td>";
echo "<td>[b]$gender[$t_gender][/b]</td>
</tr>";
}

?>

That's all map locations excluding transports and test locations.

Link to comment
Share on other sites

From DBC file.

ID    Name
------------------------------------------

0    Eastern Kingdoms
1    Kalimdor
13    Testing
25    Scott Test
29    CashTest
30    Alterac Valley
33    Shadowfang Keep
34    Stormwind Stockade
35    <unused>StormwindPrison
36    Deadmines
37    Azshara Crater
42    Collin's Test
43    Wailing Caverns
44    <unused> Monastery
47    Razorfen Kraul
48    Blackfathom Deeps
70    Uldaman
90    Gnomeregan
109    Sunken Temple
129    Razorfen Downs
169    Emerald Dream
189    Scarlet Monastery
209    Zul'Farrak
229    Blackrock Spire
230    Blackrock Depths
249    Onyxia's Lair
269    Opening of the Dark Portal
289    Scholomance
309    Zul'Gurub
329    Stratholme
349    Maraudon
369    Deeprun Tram
389    Ragefire Chasm
409    Molten Core
429    Dire Maul
449    Alliance PVP Barracks
450    Horde PVP Barracks
451    Development Land
469    Blackwing Lair
489    Warsong Gulch
509    Ruins of Ahn'Qiraj
529    Arathi Basin
530    Outland
531    Ahn'Qiraj Temple
532    Karazhan
533    Naxxramas
534    The Battle for Mount Hyjal
540    Hellfire Citadel: The Shattered Halls
542    Hellfire Citadel: The Blood Furnace
543    Hellfire Citadel: Ramparts
544    Magtheridon's Lair
545    Coilfang: The Steamvault
546    Coilfang: The Underbog
547    Coilfang: The Slave Pens
548    Coilfang: Serpentshrine Cavern
550    Tempest Keep
552    Tempest Keep: The Arcatraz
553    Tempest Keep: The Botanica
554    Tempest Keep: The Mechanar
555    Auchindoun: Shadow Labyrinth
556    Auchindoun: Sethekk Halls
557    Auchindoun: Mana-Tombs
558    Auchindoun: Auchenai Crypts
559    Nagrand Arena
560    The Escape From Durnholde
562    Blade's Edge Arena
564    Black Temple
565    Gruul's Lair
566    Eye of the Storm
568    Zul'Aman
571    Northrend
572    Ruins of Lordaeron
573    ExteriorTest
574    Utgarde Keep
575    Utgarde Pinnacle
576    The Nexus
578    The Oculus
580    The Sunwell
582    Transport: Rut'theran to Auberdine
584    Transport: Menethil to Theramore
585    Magister's Terrace
586    Transport: Exodar to Auberdine
587    Transport: Feathermoon Ferry
588    Transport: Menethil to Auberdine
589    Transport: Orgrimmar to Grom'Gol
590    Transport: Grom'Gol to Undercity
591    Transport: Undercity to Orgrimmar
592    Transport: Borean Tundra Test
593    Transport: Booty Bay to Ratchet
594    Transport: Howling Fjord Sister Mercy (Quest)
595    The Culling of Stratholme
596    Transport: Naglfar
597    Craig Test
598    Sunwell Fix (Unused)
599    Halls of Stone
600    Drak'Tharon Keep
601    Azjol-Nerub
602    Halls of Lightning
603    Ulduar
604    Gundrak
605    Development Land (non-weighted textures)
606    QA and DVD
607    Strand of the Ancients
608    Violet Hold
609    Ebon Hold
610    Transport: Tirisfal to Vengeance Landing
612    Transport: Menethil to Valgarde
613    Transport: Orgrimmar to Warsong Hold
614    Transport: Stormwind to Valiance Keep
615    The Obsidian Sanctum
616    The Eye of Eternity
617    Dalaran Sewers
618    The Ring of Valor
619    Ahn'kahet: The Old Kingdom
620    Transport: Moa'ki to Unu'pe
621    Transport: Moa'ki to Kamagua
622    Transport: Orgrim's Hammer
623    Transport: The Skybreaker
624    Vault of Archavon
628    Isle of Conquest
631    Icecrown Citadel Raid
632    Forge of Souls
641    Transport: A Airship (BG)
642    Transport: H Airship (BG)
647    Transport: Orgrimmar to Thunderbluff
649    Argent Tournament Raid
650    Argent Tournament Dungeon
658    Pit Of Saron
668    Halls of Reflection
672    Transport: A Airship (ICC Raid)
673    Transport: H Airship (ICC Raid)
712    Transport: A Airship (ICC Dungeon)
713    Transport: H Airship (ICC Dungeon)
718    Transport: The Mighty Wind (ICC Raid)
723    Stormwind
724    The Ruby Sanctum 

Link to comment
Share on other sites

Scripz looks nice but there must be a Error because Site stays white^^

Are you talking about the one I altered or all of these scripts? You say "scripz" and not "script" so I'm not sure if you mean just mine or all as the 'z' denotes a plural.

The location part is fine for me, here is my link - http://earthwalker.servegame.com/erk/showonlineppl.php

Link to comment
Share on other sites

....

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_map = $row['map'];

$t_gender = $row['gender'];

echo "<tr>

<td>$t_name</td>";

echo "<td>$race[$t_race]</td>";

echo "<td>$class[$t_class]</td>";

echo "<td>$t_lvl</td>";

echo "<td>$map[$t_map]</td>";

echo "<td>$gender[$t_gender]</td>

</tr>";

}

....

Less variables,

Less cycles unnecessary,

Less execution time.

    if($num_online > 0) 
   {
       while (($row = mysql_fetch_array($result)) != false)
       {
           echo "<tr>" .
                "<td>[b]" . $row['name'] . "[/b]</td>" .
                "<td>[b]" . $row['race'] . "[/b]</td>" .
                "<td>[b]" . $row['class'] . "[/b]</td>" .
                "<td>[b]" . $row['level'] . "[/b]</td>" .
                "<td>[b]" . $row['map'] . "[/b]</td>" .
                "<td>[b]" . $row['gender'] . "[/b]</td>" .
                "</tr>";
       }
   }
   else
   {
       echo "<tr>" . 
            "<td colspan='6' align='center'>No Players Online!</td>" .
            "</tr>";
   }

Link to comment
Share on other sites

  • 3 weeks later...

how can i show all my characters and not all characters on the realm who are online?

when i registrate in a forum i will get a id and can it be that its the same id for my game accont.

how can i say that i want see only my character.

i have a second question:

what must i do to see icons like human-male or human-female and not see class= human and gender=male

Link to comment
Share on other sites

@wowgamer,

let me know if this what you want:

<?php
$reading = @fopen("config.php", 'r');
if ($reading)               // if we can read the config.php file that's on the frontpage...
   include "config.php";
else                           // else, we define them here
{
   $port = "3306";
   $host = "localhost";
   $user = "root";
   $pass = "mangos"; 
   $mangoscharacters = "characters";
   $mangosrealm = "realmd";
}
if (!(isset($_COOKIE['logged_in'])) && $_POST['password'] == "")    // if the form is not posted and the cookie not present
{
   ?>
   <html>
   <body>
   <form name="login" method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>">
       Username: <input type="text" name="username">
       Password: <input type="password" name="password">
       <input type="submit" value="Log in">
   </form>
   </body>
   </html>
   <?php
}
else if (($_POST['username'] != "" && $_POST['password'] != "") || isset($_COOKIE['logged_in']))  // if something was posted or the cookie is present
{
   if (!isset($_COOKIE['logged_in']))       // get the name and pass from the form and make the pass sha encrypted
   {
       $username = $_POST['username'];
       $password = $_POST['password'];
       $username = strtoupper($username);
       $password = strtoupper($password);
       $password = SHA1($username.':'.$password);
   }
   else                      // else, we read the cookie
   {
       $parts = explode(",", $_COOKIE['logged_in']);          // split the cookie's contents at the comma
       $username = $parts[0];                         // part 1 is the username
       $password = $parts[1];                         // part 2 is the password
   }
   $host = $host.":".$port;
   $connection = mysql_connect($host, $user, $pass);
   if ($connection)
       $connected_db = mysql_select_db($mangosrealm);
   if ($connection && $connected_db)
   {
       $query = mysql_query("SELECT `sha_pass_hash`, `id` FROM `account` WHERE `username` = '$username';");
       if (mysql_num_rows($query) != 0)
       {
           $fields = mysql_fetch_assoc($query);
           $real_pass = $fields['sha_pass_hash'];
           $id = $fields['id'];
           if ($password == $real_pass)
           {
               setcookie("logged_in", "$username, $password", time()+600);
               mysql_select_db($mangoscharacters);
               $getchars = mysql_query("SELECT * FROM `characters` WHERE `account` = '$id';");    //query to get all the char fields from the DB
               if ($getchars)
               {
                   $charinfo = mysql_fetch_assoc($getchars);     // get all the fields from the query
                   echo '
                       <table>
                           <tr>
                               <th>| Name</th>         // display the column names
                               <th>| Race</th>
                               <th>| Class</th>
                               <th>| Level</th>
                           </tr>
                           <tr>
                               <td>| '.$charinfo['name'].'</td>         // display the content of field "name"
                               <td>| '.$charinfo['race'].'</td>
                               <td>| '.$charinfo['class'].'</td>
                               <td>| '.$charinfo['level'].'</td>
                           </tr>
                       </table>
                   ';
               }
               else
                   die("You don't have any characters");
           }
           else
               die("Wrong pass!");
       }
       else
           die("Account does not exist!");
   }
}
?>

NOTES:

- You can print the other fields from "characters" as well using the same way as i did the current 4

- You can use the cookie made by the script on ANY page you want, it contains the username and sha encrypted password (in my code, there's also an example on how to read it ;)

Link to comment
Share on other sites

thanks, it works fine! :)

$charinfo = mysql_fetch_assoc($getchars); // get all the fields from the query

echo '

<table>

<tr>

<th>| Name</th>

<th>| Race</th>

<th>| Class</th>

<th>| Level</th>

</tr>

<tr>

<td>| '.$charinfo['name'].'</td>

<td>| '.$charinfo['race'].'</td>

<td>| '.$charinfo['class'].'</td>

<td>| '.$charinfo['level'].'</td>

</tr>

</table>

- how can i say here if class is 3 then show me "druide" or something like this?

- and how can i show a picture like "human-warrior" -> a table-part from "gender" and "race"?

when i close the browser-tab after i had login with my account, and i open it again the browser shows me "Wrong pass!" but not the login-window. after a few minutes then it works normaly again.

Link to comment
Share on other sites

New version, fixed the login issue with the cookie and changed the race/class numbers to words and added map and gender :)

<?php
$CookieExpireTime = "600";         // cookie get's deleted by the browser in 600 seconds (AKA 10 minutes)
$reading = @fopen("config.php", 'r');
if ($reading)               // if we can read the config.php file that's on the frontpage...
   include "config.php";
else                           // else, we define them here
{
   $port = "3306";
   $host = "localhost";
   $user = "root";
   $pass = "mangos"; 
   $mangoscharacters = "characters";
   $mangosrealm = "realmd";
}
if (!(isset($_COOKIE['logged_in'])) && ($_POST['password'] == "" || $_POST['username'] == ""))    // if the form is not posted and the cookie not present
{
   ?>
   <html>
   <body>
   <form name="login" method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>">
       Username: <input type="text" name="username">
       Password: <input type="password" name="password">
       <input type="submit" value="Log in">
   </form>
   </body>
   </html>
   <?php
}
else if (($_POST['username'] != "" && $_POST['password'] != "") || isset($_COOKIE['logged_in']))  // if something was posted or the cookie is present
{
   if (!isset($_COOKIE['logged_in']))       // get the name and pass from the form and make the pass sha encrypted
   {
       $username = $_POST['username'];
       $password = $_POST['password'];
       $username = strtoupper($username);
       $password = strtoupper($password);
       $password = SHA1($username.':'.$password);
   }
   else                      // else, we read the cookie
   {
       $parts = explode(",", $_COOKIE['logged_in']);          // split the cookie's contents at the comma
       $username = $parts[0];                         // part 1 is the username
       $password = $parts[1];                         // part 2 is the password
   }

   $class = array(1=>"Warrior",2=>"Paladin",3=>"Hunter",4=>"Rogue",5=>"Priest",6=>"Death Knight",7=>"Shaman",8=>"Mage",9=>"Warlock",11=>"Druid");
   $race = array(1=>"Human",2=>"Orc",3=>"Dwarf",4=>"Night Elf",5=>"Undead",6=>"Tauren",7=>"Gnome",8=>"Troll",10=>"Blood Elf",11=>"Draenei");
   $map = array(0=>"Eastern Kingdoms",1=>"Kalimdor",33=>"Shadowfang Keep",34=>"Stormwind Stockade",35=>"Stormwind Prison",36=>"Deadmines",43=>"Wailing Caverns",44=>"Monastery",47=>"Razorfen Kraul",48=>"Blackfathom",70=>"Uldaman",90=>"Gnomeragon",109=>"Sunken Temple",129=>"Razorfen Downs",169=>"Emerald Dream",189=>"Monastery",209=>"Tanaris",229=>"Black Rock Spire",230=>"Black Rock Depths",249=>"Onyxia Lair",269=>"Caverns Of Time",289=>"School of Necromancy",309=>"Zulgurub",329=>"Stratholme",349=>"Mauradon",369=>"Deeprun Tram",389=>"Orgrimmar",409=>"MoltenCore",429=>"DireMaul",469=>"Blackwing Lair",509=>"AhnQiraj",530=>"Dalaran",531=>"AhnQiraj Temple",532=>"Karazahn",533=>"Stratholme",534=>"Hyjal Past",540=>"Hellfire Military",542=>"Hellfire Demon",543=>"Hellfire Rampart",544=>"Hellfire Raid",545=>"Coilfang Pumping",546=>"Coilfang Marsh",547=>"Coilfang Draenei",548=>"Coilfang Raid",550=>"Tempest Keep Raid",552=>"Tempest Keep Arcane",553=>"Tempest Keep Atrium",554=>"Tempest Keep Factory",555=>"Auchindoun Shadow",556=>"Auchindoun Demon",557=>"Auchindoun Ethereal",558=>"Auchindoun Draenei",560=>"Hillsbrad Past",562=>"Blades Edge Arena",564=>"Black Temple",565=>"Gruuls Lair",566=>"Netherstorm BG",568=>"ZulAman",571=>"Northrend",574=>"Valgarde 70",575=>"Utgarde Pinnacle",576=>"Nexus 70",578=>"Nexus 80",580=>"Sunwell Plateau",595=>"Stratholme COT",598=>"Sunwell 5",599=>"Ulduar 70",600=>"Drak Theron Keep",602=>"Ulduar 80",603=>"Ulduar Raid",604=>"GunDrak",607=>"Northrend BG",608=>"Violet Hold",609=>"Ebon Hold",615=>"The Obsidian Sanctum",616=>"The Eye of Eternity",617=>"Dalaran Sewers",618=>"The Ring of Valor",619=>"Ahn'kahet: The Old Kingdom",624=>"Vault of Archavon",628=>"Isle of Conquest",631=>"Icecrown Citadel Raid",632=>"Forge of Souls",649=>"Argent Tournament Raid",650=>"Argent Tournament Dungeon",658=>"Pit Of Saron",668=>"Halls of Reflection",723=>"Stormwind",724=>"The Ruby Sanctum");
   $gender = array(0=>"Male",1=>"Female");

   $host = $host.":".$port;
   $connection = mysql_connect($host, $user, $pass);
   if ($connection)
       $connected_db = mysql_select_db($mangosrealm);
   if ($connection && $connected_db)
   {
       $query = mysql_query("SELECT `sha_pass_hash`, `id` FROM `account` WHERE `username` = '$username';");
       if (mysql_num_rows($query) != 0)
       {
           $fields = mysql_fetch_assoc($query);
           $real_pass = $fields['sha_pass_hash'];
           $id = $fields['id'];
           if ($password == $real_pass)
           {
               setcookie("logged_in", $username.",".$password, time()+$CookieExpireTime);
               mysql_select_db($mangoscharacters);
               $getchars = mysql_query("SELECT * FROM `characters` WHERE `account` = '$id';");    //query to get all the char fields from the DB
               if ($getchars)
               {
                   $charinfo = mysql_fetch_assoc($getchars);     // get all the fields from the query
                   echo '
                       <table border="0.5">
                           <tr>
                               <th>Name</th>
                               <th>Race</th>
                               <th>Class</th>
                               <th>Level</th>
                               <th>Map</th>
                               <th>Gender</th>
                           </tr>
                           <tr>
                               <td>'.$charinfo['name'].'</td>
                               <td>'.$race[$charinfo['race']].'</td>
                               <td>'.$class[$charinfo['class']].'</td>
                               <td>'.$charinfo['level'].'</td>
                               <td>'.$map[$charinfo['map']].'</td>
                               <td>'.$gender[$charinfo['gender']].'</td>
                           </tr>
                       </table>
                   ';
               }
               else
                   die("You don't have any characters");
           }
           else
               die("Wrong pass!");
       }
       else
           die("Account does not exist!");
   }
}
?>

Edit: added variable on the top so you can set the cookie's expire time

Edit2: If you want an image to be displayed next to the race, you could change

<td>'.$race[$charinfo['race']].'</td>

into

<td>[img=img/'.$race[$charinfo['race']].'.jpg] '.$race[$charinfo['race']].'</td>

this will load the image "tauren.jpg" from the "img" subfolder, which you'll have to supply yourself, if your race is "tauren" ( $race[$charinfo['race']] returns the racename )

Link to comment
Share on other sites

yeah it works fine.

- i dont know why but i can see only my first char and the other chars not

- what must i do for make a kombination with race and gender (like human->1 and gender->0 : show img 1-0.jpg) (like human->1 and gender->1 : show img 1-1.jpg)

sorry that i cant show you the pics.

on the pictures you can see on race human-male-pic, human-female-pic, orc-male-pic, orc-female-pic,...

Link to comment
Share on other sites

For some reason the Top honor script shows blank when i use it, is it me or does it just need some updating?

You're right, it doesn't work....

fixed 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 * 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);
?>

NOTE: Made some usefull changes as well

Link to comment
Share on other sites

×
×
  • 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