Jump to content

Recommended Posts

  • Replies 171
  • Created
  • Last Reply

Top Posters In This Topic

Posted

I have this script

<?php

include ("config.php");

$characters = mysql_connect("$host", "$user", "$pass") or die('Connection Failed');

mysql_select_db ("$mangosrealm");

$result = mysql_query("SELECT * FROM `voting_points` ORDER BY `points` DESC LIMIT 0 , 20 "); 

?>
   <table align=center cellpadding="0" cellspacing="0"  border="1" width="350px">
   <thead>            
   <p align="center" class="style1">Top Voter</p>
     <tr><td colspan="5"><div align="center" style="font-size:14px; color:#ffcc00;">[b]Top Voter[/b]</div></td>
     </tr>
   <td width="4%"><center>Rank</center></td>
       <td width="16%"><center>Account name</center></td>
       <td width="5%"><center>Point</center></td>
   </thead>
   <tbody>

<?php

while($rows = mysql_fetch_object($result)) 
{ 
$i++; 
$Pid = $rows->id; 
$Point = $rows->points;
   echo " 
<tr>
<td><center>",$i,"</center></td>
<td>[i]",$Pid,"[/i]</td>
<td><center>",$Point,"</center></td>
</tr>"; 
} 

   mysql_close($characters);
?>


I want instead of account ID show username

Sorry im english not good

Posted

If you have an ID you can join two tables...

Like this:

SELECT b.username, a.rank, a.points FROM voting_points a INNER JOIN account b ON (a.id = b.id) ORDER BY a.points DESC LIMIT 0 , 20

Posted

Try this.

<?php

   include ("config.php");
   //---->
   $characters = mysql_connect("$host", "$user", "$pass")
                        or die('Connection Failed');
   //---->
   mysql_select_db ("$mangosrealm");
   //---->
   $result = mysql_query("SELECT b.username, a.rank, a.points FROM voting_points a INNER JOIN account b ON (a.id = b.id) ORDER BY a.points DESC LIMIT 20;"); 

?>
   <table align=center cellpadding="0" cellspacing="0"  border="1" width="350px">
       <thead>            
           <tr>
               <td colspan="3">
                   <div align="center" style="font-size:14px; color:#ffcc00;">
                       [b]Top Voter[/b]
                   </div>
               </td>
           </tr>        
           <tr>
               <td width="40%"><center>AccountName</center></td>
       <td width="30%"><center>Rank</center></td>
       <td width="30%"><center>Point</center></td>        
           </tr>
       </thead>
       <tbody>

<?php

   while(($rows = mysql_fetch_object($result)) != false) 
   { 
       echo "<tr>" .
       "<td>[i]" . $rows->username . "[/i]</td>" .
       "<td><center>" . $rows->rank . "</center></td>" .
       "<td><center>" . $rows->points . "</center></td>" .
       "</tr>"; 
   } 
   //---->
   mysql_free_result($result);
   mysql_close($characters);

?>

       </tbody>
   </table>

Posted

Error :

Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in C:\\xampp\\htdocs\\st\\topvoter.php on line 32
Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in C:\\xampp\\htdocs\\st\\topvoter.php on line 41

Posted

Top honor doesn't work :

Warning: Unexpected character in input: ''' (ASCII=39) state=1 in /var/www/site/site/top_honneur.php on line 7

Parse error: syntax error, unexpected T_STRING in /var/www/site/site/top_honneur.php on line 7

Posted
srry for bumping this, but with second uptime script i get wrong days "1281723278" o.0, any one know why? i was using the first but i like the 2cnd

I tried that code on my server and got the same results, but then I noticed the code itself had some typos and just seemed unfinished. Here's some working code based off of the 2nd uptime example that does work

<?php
require_once ('config.php');
mysql_connect($host, $user, $pass) or die ("Can't connect with $host");
mysql_select_db ("$mangosrealm");

$result = mysql_query ("SELECT `starttime` FROM $mangosrealm.`uptime` ORDER BY `starttime` DESC LIMIT 1");  
$curtime = time() - mysql_result($result,0,0);
$sec = $curtime%(60);
$min = floor(($curtime/60)%60);
$hours = floor(($curtime/(60*60))%24);
$days = floor($curtime/(60*60*24));

echo "Time Online: $days days $hours hrs $min min $sec sec
";
?>

Edit: Changed query so that it requests only the `starttime` and none of the others

Posted
I tried that code on my server and got the same results, but then I noticed the code itself had some typos and just seemed unfinished. Here's some working code based off of the 2nd uptime example that does work

<?php
require_once ('config.php');
mysql_connect($host, $user, $pass) or die ("Can't connect with $host");
mysql_select_db ("$mangosrealm");

$result = mysql_query ("SELECT * FROM $mangosrealm.`uptime` ORDER BY `starttime` DESC LIMIT 1");  
$curtime = time() - mysql_result($result,0,1);
$sec = $curtime%(60);
$min = floor(($curtime/60)%60);
$hours = floor(($curtime/(60*60))%24);
$days = floor($curtime/(60*60*24));

echo "Time Online: $days days $hours hrs $min min $sec sec
";
?>

tnx for your fast answer, and here is mine xD, i think that still have some errors caus at server uptime column i have 75600 that is 21 hours right? 75600/3600 if im right. the script show 12 hours

Posted

The code I provided uses the field `starttime` and compares that to php's time() function. In my case the code reports the same time that MaNGOS reports with .server info

Maybe your server uses one timezone while php is using another?

Edit: Actually I just changed my host system / mysql to use GMT, while PHP is using CST6CDT (America/Chicago) and I was not able to reproduce any incorrect uptime values compared to what ".server info" returns

[irrelevant Edits Removed]

Posted
The code I provided uses the field `starttime` and compares that to php's time() function. In my case the code reports the same time that MaNGOS reports with .server info

Maybe your server uses one timezone while php is using another?

Edit: Actually I just changed my host system / mysql to use GMT, while PHP is using CST6CDT (America/Chicago) and I was not able to reproduce any incorrect uptime values compared to what ".server info" returns

no no my apologize, i was checking the most ever uptime that was 75600 not the current uptime its perfectly 48600/3600 13.5 hours that is what is showing me also the same at the .server info.

tnx for your rply my fault. should be good if someone update the code at first page

  • 2 weeks later...
Posted
Has someone a Player Online Script which works ^^ The One on this Page won't work out of Errors an when I got working it the Player show on Page without Order.

Greez Andy

<?php
$ip = "";
$port = "";
$host = "";
$user = "";
$pass = ""; 
$mangoscharacters = "";

$conn = mysql_connect($host, $user, $pass) or die('Connection failed: ' . mysql_error());

mysql_select_db($mangoscharacters, $conn) or die('Select DB failed: ' . mysql_error());

$sql = "SELECT Count(Online) FROM `characters` WHERE `online` = 1";
$result = mysql_query($sql, $conn);
$row = mysql_fetch_array($result);
$online = $row["Count(Online)"];

echo "Amount of players online at this time: " . $online; 
?>

test that out, if it doesn't work tell me the steps you took

Posted

Noob alert. Can someone post a small tutorial as to...what to do with these scripts?

As in, where would I put this? :-

<?
require_once ( 'config.php');
$conn = mysql_connect($host, $user, $pass) or die('Connection failed: ' . mysql_error());

mysql_select_db($mangoscharacters, $conn) or die('Select DB failed: ' . mysql_error());

$sql = "SELECT Count(Online) FROM `characters` WHERE `online` = 1";
$result = mysql_query($sql, $conn);
$row = mysql_fetch_array($result);
$online = $row["Count(Online)"];

echo $online;

?> 

inside the index.html or have the index.html have a line like load.code.php.

It's all very confusing to me :D

Don't laugh, or I may spontaneously combust :P

Posted
i need script for

- unstuck

- bancheck ip , bancheckacc , bancheckchar ==> ( login and bancheck )

Check BanIP (realmd database)

$res = mysql_query("SELECT ip from ip_banned WHERE ip = '".$_SERVER["REMOTE_ADDR"]."' LIMIT 1");

Check BanAcc (realmd database)

$res = mysql_query("SELECT a.id FROM account_banned a WHERE a.id = (SELECT b.id FROM account b WHERE username = "#username_to_upper" LIMIT 1) LIMIT 1");

PHP Check on "Num Rows"

<?php

    if(mysql_num_rows($res) > 0)
          echo "Banned";
    else {
          // other procedures....
    }

?>

Posted

<center><table border="2" width="70%">
 <tr>
  <td>[b]Name:    [/b]</td>
  <td>[b]Rasse:    [/b]</td>
  <td>[b]Klasse:    [/b]</td>
  <td>[b]Level:    [/b]</td>
  <td>[b]Geschlecht:    [/b]</td>
 </tr>
<?

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=>"Krieger",2=>"Paladin",3=>"Jäger",4=>"Schurke",5=>"Priester",6=>"Todesritter",7=>"Schamane",8=>"Magier",9=>"Hexenmeister",11=>"Druide");
$race = array(1=>"Mensch",2=>"Orc",3=>"Zwerg",4=>"Nacht Elf",5=>"Untoter",6=>"Tauren",7=>"Gnom",8=>"Troll",10=>"Blutelf",11=>"Dranei");
$gender = array(0=>"Männlich",1=>"Weiblich");

if($num_online < 1) {
 echo "<tr><td colspan='4' align='center'>Keine Spieler 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>";

}

if you want a background in it use

echo "<body style=\\"background-image:url(images/worldmap.gif)\\">";

Its editet for German Homepages with the Names of the Gender,Classes..

Posted
Noob alert. Can someone post a small tutorial as to...what to do with these scripts?...

<?

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

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

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

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

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

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

?> 

You must use the script into a PHP file such as: index.php.

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