[HELP]SCRIPT PHP PLAYERS ONLINE

11/24/2009 11:14 *JayKay*#1
Not know much about PHP I'M WITH A DOUBT AS AGENT IN AN ONLINE PLAYERS SYNTAX WHAT IT IN TIME FOR YOU TO READ THE DATABASE NOT READ NAMES OF FILES CONTAINING "[" SO READ NAMES normally someone can tell me?
EXAMPLE: READING THIS filesdir [DEV], [GM] ...
BELOW IS THE FILE:
PHP Code:
<style type="text/css">
<!--
body,td,th {
    font-family: Verdana, Geneva, sans-serif;
    color: #FFFF00;
    font-weight: bold;
}
body {
    background-color: #000;
}
-->
</style><center>
<h1 class="style1"> Players Online </h1>
</style><center>
<?php

$mssql 
= array(
        
'host' => "11111",
        
'user' => "sa",
        
'pass' => "11111"
    
);
    
echo 
"<center><br><br>";
echo 
"<table border='1'>
    <tr>
        <td align='center'>Character Name</td>
        <td align='center'>Level</td>
        <td align='center'>Map</td>
        <td align='center'>Login</td>

    </tr>"
;

$con mssql_connect($mssql['host'],$mssql['user'],$mssql['pass']);

$result1 mssql_query("SELECT user_no FROM account.dbo.USER_PROFILE WHERE login_flag = '1100'",$con);


while(
$row1 mssql_fetch_row($result1)) {
    
    
$result2 mssql_query("SELECT character_name,wLevel,wMapIndex,login_time FROM character.dbo.user_character WHERE user_no = '".$row1[0]."' ORDER by login_time DESC",$con);
    
$row2 mssql_fetch_row($result2);

        echo 
"<tr>
            <td align='left'>"
.$row2[0]."</td>
            <td align='center'>"
.$row2[1]."</td>
            <td align='center'>"
.$row2[2]."</td>
            <td align='center'>"
.$row2[3]."</td>

        </tr>"
;

}
echo 
"</table></center>";
?>
THANKS.
11/24/2009 14:10 gedimazs#2
Don't understand what you want :) Have you used translator?
11/24/2009 14:24 *JayKay*#3
Quote:
Originally Posted by gedimazs View Post
Don't understand what you want :) Have you used translator?
this friend and a php script called playersonline.php when I click it appears all the players who are online on my server including [GM] the question is:
which syntax or code does not appear to use the more [GM] know there is a syntax for this but do not know where to find and place can help?


[Only registered and activated users can see links. Click Here To Register...]
11/24/2009 14:34 bottomy#4
Quote:
Originally Posted by arthurvalenca View Post
this friend and a php script called playersonline.php when I click it appears all the players who are online on my server including [GM] the question is:
which syntax or code does not appear to use the more [GM] know there is a syntax for this but do not know where to find and place can help?

lol i don't understand what you're talking about either. but if i get what i think you're asking than, there isn't any specific code for getting the [GM] chars. it's just selecting getting all chars that are online.
11/24/2009 14:39 *JayKay*#5
Quote:
Originally Posted by bottomy View Post
lol i don't understand what you're talking about either. but if i get what i think you're asking than, there isn't any specific code for getting the [GM] chars. it's just selecting getting all chars that are online.
look my image.

thanks.
11/24/2009 14:49 bottomy#6
i get what you want now. just add a WHERE character_name <> '[' or something like that i think.

PHP Code:
$result2 mssql_query("SELECT character_name,wLevel,wMapIndex,login_time FROM character.dbo.user_character WHERE character_name <> '[' AND user_no = '".$row1[0]."' ORDER by login_time DESC",$con); 
im not sure if it gonna just check first letter [ or if it gonna check exactly.


EDIT: yeh it gonna check for exactly [ so do this instead

PHP Code:
$result2 mssql_query("SELECT character_name,wLevel,wMapIndex,login_time FROM character.dbo.user_character WHERE character_name NOT LIKE '[%' AND user_no = '".$row1[0]."' ORDER by login_time DESC",$con); 
11/24/2009 15:50 *JayKay*#7
Quote:
Originally Posted by bottomy View Post
i get what you want now. just add a WHERE character_name <> '[' or something like that i think.

PHP Code:
$result2 mssql_query("SELECT character_name,wLevel,wMapIndex,login_time FROM character.dbo.user_character WHERE character_name <> '[' AND user_no = '".$row1[0]."' ORDER by login_time DESC",$con); 
im not sure if it gonna just check first letter [ or if it gonna check exactly.


EDIT: yeh it gonna check for exactly [ so do this instead

PHP Code:
$result2 mssql_query("SELECT character_name,wLevel,wMapIndex,login_time FROM character.dbo.user_character WHERE character_name NOT LIKE '[%' AND user_no = '".$row1[0]."' ORDER by login_time DESC",$con); 
dont work.
11/24/2009 16:28 Nosferatu.#8
try this way:

PHP Code:
function getgm($gm){

$gmstatus $gm[0].$gm[1].$gm[2].$gm[3];

if(
$gmstatus == '[GM]')
 {
   Return 
'GameMaster';
 }  
 else
 {
  Return 
'User';
 }

}

/* her your other code MSSQL ... */

while($row1 mssql_fetch_row($result1)) {
    
    
$result2 mssql_query("SELECT character_name,wLevel,wMapIndex,login_time FROM character.dbo.user_character WHERE user_no = '".$row1[0]."' ORDER by login_time DESC",$con);
    
$row2 mssql_fetch_row($result2);

if (
getgm($row2->character_name) == 'User') {

        echo 
"<tr>
            <td align='left'>"
.$row2[0]."</td>
            <td align='center'>"
.$row2[1]."</td>
            <td align='center'>"
.$row2[2]."</td>
            <td align='center'>"
.$row2[3]."</td>

        </tr>"
;

 }  

11/24/2009 16:41 Zombe#9
So u want to retieve GMs from mssql? I can't understand what you want, cuz ur english sucks REALLY bad.

Try this:

PHP Code:
<?php 
/* -------------{The get all GMs page by Zombe}------------- */ 

$MSSQLserverIP 'localhost'// IP goes here 
$MSSQLusername 'sa'// MSSQL username goes here 
$MSSQLpassword 'password'// MSSQL password goes here 

//        Don't edit below if you don't know what you are doing. 

$link mssql_connect ("$MSSQLserverIP""$MSSQLusername""$MSSQLpassword"); 

$result mssql_query("SELECT * FROM character.dbo.user_character WHERE character_name LIKE '_GM%'",$link); 
while (
$record mssql_fetch_array($result)) 

    echo 
"$record[character_name]<br>"
}
?>




EDIT: Ohhh, you want to EXCLUDE gms?
ok, do this:
find where it says
PHP Code:
 $result2 mssql_query("SELECT character_name,wLevel,wMapIndex,login_time FROM character.dbo.user_character WHERE user_no = '".$row1[0]."' ORDER by login_time DESC",$con); 
And replace it with
PHP Code:
 $result2 mssql_query("SELECT character_name,wLevel,wMapIndex,login_time FROM character.dbo.user_character WHERE user_no = '".$row1[0]."' AND character_name NOT LIKE _GM% ORDER by login_time DESC",$con); 
then no gms will show up.
11/24/2009 18:31 caper#10
Quote:
Originally Posted by Zombe View Post
So u want to retieve GMs from mssql? I can't understand what you want, cuz ur english sucks REALLY bad.

Try this:

PHP Code:
<?php 
/* -------------{The get all GMs page by Zombe}------------- */ 

$MSSQLserverIP 'localhost'// IP goes here 
$MSSQLusername 'sa'// MSSQL username goes here 
$MSSQLpassword 'password'// MSSQL password goes here 

//        Don't edit below if you don't know what you are doing. 

$link mssql_connect ("$MSSQLserverIP""$MSSQLusername""$MSSQLpassword"); 

$result mssql_query("SELECT * FROM character.dbo.user_character WHERE character_name LIKE '_GM%'",$link); 
while (
$record mssql_fetch_array($result)) 

    echo 
"$record[character_name]<br>"
}
?>




EDIT: Ohhh, you want to EXCLUDE gms?
ok, do this:
find where it says
PHP Code:
 $result2 mssql_query("SELECT character_name,wLevel,wMapIndex,login_time FROM character.dbo.user_character WHERE user_no = '".$row1[0]."' ORDER by login_time DESC",$con); 
And replace it with
PHP Code:
 $result2 mssql_query("SELECT character_name,wLevel,wMapIndex,login_time FROM character.dbo.user_character WHERE user_no = '".$row1[0]."' AND character_name NOT LIKE _GM% ORDER by login_time DESC",$con); 
then no gms will show up.

That will work but it will exclude any regular player names such as "GGMll" or "sGMres" for example.

You are better off looking for the actual "[GM]" tag by using this at the end:

not like '[GM]%';

or just the bracket

not like '[%';

or even escape it if

not like '![%' escape '!'

Haven't tested these with mssql but they all work in postgresql.
11/24/2009 23:22 *JayKay*#11
Thanks all the correct syntax and
PHP Code:
$result2 mssql_query("SELECT character_name,wLevel,wMapIndex,login_time FROM character.dbo.user_character WHERE user_no = '".$row1[0]."' AND character_name NOT LIKE '_GM%' ORDER by login_time DESC",$con); 
11/25/2009 09:27 Zombe#12
Quote:
Originally Posted by caper View Post
That will work but it will exclude any regular player names such as "GGMll" or "sGMres" for example.

You are better off looking for the actual "[GM]" tag by using this at the end:

not like '[GM]%';

or just the bracket

not like '[%';

or even escape it if

not like '![%' escape '!'

Haven't tested these with mssql but they all work in postgresql.
Seel, in the LIKE sql statement, you can't use [ and ] symbols.
Also, if you know, you can't use GM in your name even without the brackets, if you don't use GM hack, so non-hackers can't make a name like "sGMres".
I could make it with brackets by getting GMs form SQL and the filtering em out with preg_match(), but that's more to think about, and I just wanted to make it quick xD
04/12/2011 15:39 TraxWall#13
Hy.

Bye.

not good for me.

you normally would not write off that rain is a good file server?