Jump to content

Gaming server PHP script help...


SmoshySmosh

Recommended Posts

<?php

include_once('config.php');

mysql_connect($CONFIG_db_serv, $CONFIG_db_user, $CONFIG_db_pass );

mysql_select_db($CONFIG_rag_db);

//$result= mysql_query("SELECT * FROM `login`");

$result = mysql_query("SELECT * FROM `char` WHERE `online` = 1");

//$row = mysql_fetch_array($result);

 

 

echo "

<table width=\"550\">

<tr>

<td align=\"right\" class=\"head\">Look</td>

<td align=\"center\" class=\"head\">Name</td>

<td> </td>

<td align=\"left\" class=\"head\">Class</td>

<td> </td>

<td> </td>

<td align=\"left\" class=\"head\">Level</td>

</tr>";

$i=1;

while ($row = mysql_fetch_array($result)) {

$result2 = mysql_query("SELECT * FROM `login` WHERE `account_id` = ".$row['account_id']." ");

$row2 = mysql_fetch_array($result2);

$gender = $row['sex'];

echo " <tr>

<td align=\"right\"><img src=\"../images/$gender/".$row['hair'].".png\"></td>

<td align=\"center\">".$row['name']."</td>

<td> </td>

<td align=\"left\">$C".$row['class']."</td>

<td> </td>

<td> </td>

<td align=\"left\">".$row['base_level']."/".$row['job_level']."</td>

</tr>";

$i++;

}

 

echo "</table>";

?>

Here is my code, and here is the output http://qq-ro.com/scripts/whosonline.php

 

What i am trying to do is make the images load from the correct folders, the DB is setup so it has the character level information and almost everything else besides the gender in the char table, and the gender of the character is in the login table. I am trying to make it so it loads the correct image that corresponds to the gender of the character, as I think you can see in my code yet I cannot get it to work.... I have tried like 10 different work arounds but nothing seems to work for me... Another problem i am having is I need it to tell the character class, but the DB only gives me the class number. In config.php i set it up so the number that it spits out gives the character name if it is like $C4047 for example, yet I cannot get it to turn into that...

 

Any help is much appreciated, sorry if i did not follow the guidelines, This is my first post here and I am in such a big hurry to get this script done. :-X

 

-Smosh

Link to comment
Share on other sites

I don't see the problem. The Page works perfectly for me. I see the Pictures, Name, Class, and Level. Could you be a little more specific as what you are looking for.

 

By the Way ... You might want to add the '.' around your $gender variable, if its not showing up right.

<td align=\"right\"><img src=\"../images/$gender/".$row['hair'].".png\"></td>

Turns into

<td align=\"right\"><img src=\"../images/".$gender."/".$row['hair'].".png\"></td>

Link to comment
Share on other sites

http://qq-ro.com/images/hairs//3.png

is what I get with

		while ($row = mysql_fetch_array($result)) {
$result2 = mysql_query("SELECT * FROM `login` WHERE `account_id` = ".$row['account_id']." ");
$row2 = mysql_fetch_array($result2);
$gender = $row['sex'];
		echo "	<tr>
			<td align=\"right\"><img src=\"../images/hairs/".$gender."/".$row['hair'].".png\"></td>

when it should show up as

http://qq-ro.com/images/hairs/F/3.png

 

And I want the Classes to not show up as the numbers but show up as the actual class name.

<td align=\"left\">$C".$row['class']."</td>

//Class
$C0 = 'Novice';
$C1 = 'Swordman';
$C2 = 'Mage';
$C3 = 'Archer';
$C4 = 'Acolyte';
$C5 = 'Merchant';
$C6 = 'Thief';
$C7 = 'Knight';
$C8 = 'Priest';
$C9 = 'Wizard';
$C10 = 'Blacksmith';
$C11 = 'Hunter';
$C12 = 'Assassin';
$C14 = 'Crusader';
$C15 = 'Monk';
$C16 = 'Sage';
$C17 = 'Rogue';
$C18 = 'Alchemist';
$C19 = 'Bard';
$C20 = 'Dancer';
$C23 = 'Super Novice';
$C24 = 'Gunslinger';
$C25 = 'Ninja';
$C4001 = 'High Novice';
$C4002 = 'High Swordman';
$C4003 = 'High Mage';
$C4004 = 'High Archer';
$C4005 = 'High Acolyte';
$C4006 = 'High Merchant';
$C4007 = 'High Thief';
$C4008 = 'Lord Knight';
$C4009 = 'High Priest';
$C4010 = 'High Wizard';
$C4011 = 'Whitesmith';
$C4012 = 'Sniper';
$C4013 = 'Assassin Cross';
$C4015 = 'Paladin';
$C4016 = 'Champion';
$C4017 = 'Professor';
$C4018 = 'Stalker';
$C4019 = 'Creator';
$C4020 = 'Clown';
$C4021 = 'Gypsy';
$C4023 = 'Baby';
$C4024 = 'Baby Swordman';
$C4025 = 'Baby Mage';
$C4026 = 'Baby Archer';
$C4027 = 'Baby Acolyte';
$C4028 = 'Baby Merchant';
$C4029 = 'Baby Thief';
$C4030 = 'Baby Knight';
$C4031 = 'Baby Priest';
$C4032 = 'Baby Wizard';
$C4033 = 'Baby Blacksmith';
$C4034 = 'Baby Hunter';
$C4035 = 'Baby Assassin';
$C4037 = 'Baby Crusader';
$C4038 = 'Baby Monk';
$C4039 = 'Baby Sage';
$C4040 = 'Baby Rogue';
$C4041 = 'Baby Alchemist';
$C4042 = 'Baby Bard';
$C4043 = 'Baby Dancer';
$C4045 = 'Super Baby';
$C4046 = 'Taekwon';
$C4047 = 'Star Gladiator';
$C4049 = 'Soul Linker';

 

but they just show as the number...

 

-Smosh

 

 

 

 

Link to comment
Share on other sites

have you checked that there is a value for "sex" in the char table.

 

If there is what you can do is simply output what the array is by using this piece of code

echo "<pre>"; print_r($row); echo "</pre>";

put that after this line

while ($row = mysql_fetch_array($result)) {

 

that will tell you if the sex field is there and if it has a value.

Link to comment
Share on other sites

sex is in the login table and the rest of the stuff I am using is in the char table.

 

same error for the class

 

<td align=\"left\">$C[$row['class']];</td>

Parse error: syntax error, unexpected '[', expecting ']' in /mnt/local/home/holoc/qq-ro.com/scripts/whosonline.php on line 30

 

Array
(
    [0] => 150030
    [char_id] => 150030
    [1] => 2000028
    [account_id] => 2000028
    [2] => 0
    [char_num] => 0
    [3] => Strawberry
    [name] => Strawberry
    [4] => 10
    [class] => 10
    [5] => 95
    [base_level] => 95
    [6] => 50
    [job_level] => 50
    [7] => 23133670
    [base_exp] => 23133670
    [8] => 2083386
    [job_exp] => 2083386
    [9] => 1299145
    [zeny] => 1299145
    [10] => 99
    [str] => 99
    [11] => 9
    [agi] => 9
    [12] => 70
    [vit] => 70
    [13] => 1
    [int] => 1
    [14] => 50
    [dex] => 50
    [15] => 1
    [luk] => 1
    [16] => 8129
    [max_hp] => 8129
    [17] => 8129
    [hp] => 8129
    [18] => 401
    [max_sp] => 401
    [19] => 401
    [sp] => 401
    [20] => 5
    [status_point] => 5
    [21] => 0
    [skill_point] => 0
    [22] => 8
    [option] => 8
    [23] => 0
    [karma] => 0
    [24] => 0
    [manner] => 0
    [25] => 34
    [party_id] => 34
    [26] => 8
    [guild_id] => 8
    [27] => 0
    [pet_id] => 0
    [28] => 0
    [homun_id] => 0
    [29] => 3
    [hair] => 3
    [30] => 0
    [hair_color] => 0
    [31] => 0
    [clothes_color] => 0
    [32] => 7
    [weapon] => 7
    [33] => 0
    [shield] => 0
    [34] => 0
    [head_top] => 0
    [35] => 0
    [head_mid] => 0
    [36] => 0
    [head_bottom] => 0
    [37] => pay_fild02
    [last_map] => pay_fild02
    [38] => 156
    [last_x] => 156
    [39] => 216
    [last_y] => 216
    [40] => payon
    [save_map] => payon
    [41] => 160
    [save_x] => 160
    [42] => 58
    [save_y] => 58
    [43] => 0
    [partner_id] => 0
    [44] => 1
    [online] => 1
    [45] => 0
    [father] => 0
    [46] => 0
    [mother] => 0
    [47] => 0
    [child] => 0
    [48] => 0
    [fame] => 0
)

Link to comment
Share on other sites

This is the Array, and at the bottom is the example of how to use it. $C[$row['class']] should work fine.

 

<?php
//Class
$C[0] = 'Novice';
$C[1] = 'Swordman';
$C[2] = 'Mage';
$C[3] = 'Archer';
$C[4] = 'Acolyte';
$C[5] = 'Merchant';
$C[6] = 'Thief';
$C[7] = 'Knight';
$C[8] = 'Priest';
$C[9] = 'Wizard';
$C[10] = 'Blacksmith';
$C[11] = 'Hunter';
$C[12] = 'Assassin';
$C[14] = 'Crusader';
$C[15] = 'Monk';
$C[16] = 'Sage';
$C[17] = 'Rogue';
$C[18] = 'Alchemist';
$C[19] = 'Bard';
$C[20] = 'Dancer';
$C[23] = 'Super Novice';
$C[24] = 'Gunslinger';
$C[25] = 'Ninja';
$C[4001] = 'High Novice';
$C[4002] = 'High Swordman';
$C[4003] = 'High Mage';
$C[4004] = 'High Archer';
$C[4005] = 'High Acolyte';
$C[4006] = 'High Merchant';
$C[4007] = 'High Thief';
$C[4008] = 'Lord Knight';
$C[4009] = 'High Priest';
$C[4010] = 'High Wizard';
$C[4011] = 'Whitesmith';
$C[4012] = 'Sniper';
$C[4013] = 'Assassin Cross';
$C[4015] = 'Paladin';
$C[4016] = 'Champion';
$C[4017] = 'Professor';
$C[4018] = 'Stalker';
$C[4019] = 'Creator';
$C[4020] = 'Clown';
$C[4021] = 'Gypsy';
$C[4023] = 'Baby';
$C[4024] = 'Baby Swordman';
$C[4025] = 'Baby Mage';
$C[4026] = 'Baby Archer';
$C[4027] = 'Baby Acolyte';
$C[4028] = 'Baby Merchant';
$C[4029] = 'Baby Thief';
$C[4030] = 'Baby Knight';
$C[4031] = 'Baby Priest';
$C[4032] = 'Baby Wizard';
$C[4033] = 'Baby Blacksmith';
$C[4034] = 'Baby Hunter';
$C[4035] = 'Baby Assassin';
$C[4037] = 'Baby Crusader';
$C[4038] = 'Baby Monk';
$C[4039] = 'Baby Sage';
$C[4040] = 'Baby Rogue';
$C[4041] = 'Baby Alchemist';
$C[4042] = 'Baby Bard';
$C[4043] = 'Baby Dancer';
$C[4045] = 'Super Baby';
$C[4046] = 'Taekwon';
$C[4047] = 'Star Gladiator';
$C[4049] = 'Soul Linker';
$number['class'] = 1;
echo $C[$number['class']];
?>

Link to comment
Share on other sites

Still spits the same error at me

 

<?php
include_once('config.php'); 
mysql_connect($CONFIG_db_serv, $CONFIG_db_user, $CONFIG_db_pass ); 
mysql_select_db($CONFIG_rag_db);
//$result= mysql_query("SELECT * FROM `login`");
$result = mysql_query("SELECT * FROM `char` WHERE `online` = 1");
//$row = mysql_fetch_array($result);


	echo "
	<table width=\"550\">
	<tr>
		<td align=\"right\" class=\"head\">Look</td>
		<td align=\"center\" class=\"head\">Name</td>
		<td> </td>
		<td align=\"left\" class=\"head\">Class</td>
		<td> </td>
		<td> </td>
		<td align=\"left\" class=\"head\">Level</td>
	</tr>";
	while ($row = mysql_fetch_array($result)) {
$result2 = mysql_query("SELECT * FROM `login` WHERE `account_id` = ".$row['account_id']." ");
$row2 = mysql_fetch_array($result2);
$gender = $row2['sex'];
		echo "	<tr>
			<td align=\"right\"><img src=\"../images/hairs/".$gender."/".$row['hair'].".gif\"></td>
			<td align=\"center\">".$row['name']."</td>
			<td> </td>
			<td align=\"left\">$C[$row['class']]</td>
			<td> </td>
			<td> </td>
			<td align=\"left\">".$row['base_level']."/".$row['job_level']."</td>
			</tr>";
	}

echo "</table>";
?>

(part of config.php)

//Class
$C[0] = 'Novice';
$C[1] = 'Swordman';
$C[2] = 'Mage';
$C[3] = 'Archer';
$C[4] = 'Acolyte';
$C[5] = 'Merchant';
$C[6] = 'Thief';
$C[7] = 'Knight';
$C[8] = 'Priest';
$C[9] = 'Wizard';
$C[10] = 'Blacksmith';
$C[11] = 'Hunter';
$C[12] = 'Assassin';
$C[14] = 'Crusader';
$C[15] = 'Monk';
$C[16] = 'Sage';
$C[17] = 'Rogue';
$C[18] = 'Alchemist';
$C[19] = 'Bard';
$C[20] = 'Dancer';
$C[23] = 'Super Novice';
$C[24] = 'Gunslinger';
$C[25] = 'Ninja';
$C[4001] = 'High Novice';
$C[4002] = 'High Swordman';
$C[4003] = 'High Mage';
$C[4004] = 'High Archer';
$C[4005] = 'High Acolyte';
$C[4006] = 'High Merchant';
$C[4007] = 'High Thief';
$C[4008] = 'Lord Knight';
$C[4009] = 'High Priest';
$C[4010] = 'High Wizard';
$C[4011] = 'Whitesmith';
$C[4012] = 'Sniper';
$C[4013] = 'Assassin Cross';
$C[4015] = 'Paladin';
$C[4016] = 'Champion';
$C[4017] = 'Professor';
$C[4018] = 'Stalker';
$C[4019] = 'Creator';
$C[4020] = 'Clown';
$C[4021] = 'Gypsy';
$C[4023] = 'Baby';
$C[4024] = 'Baby Swordman';
$C[4025] = 'Baby Mage';
$C[4026] = 'Baby Archer';
$C[4027] = 'Baby Acolyte';
$C[4028] = 'Baby Merchant';
$C[4029] = 'Baby Thief';
$C[4030] = 'Baby Knight';
$C[4031] = 'Baby Priest';
$C[4032] = 'Baby Wizard';
$C[4033] = 'Baby Blacksmith';
$C[4034] = 'Baby Hunter';
$C[4035] = 'Baby Assassin';
$C[4037] = 'Baby Crusader';
$C[4038] = 'Baby Monk';
$C[4039] = 'Baby Sage';
$C[4040] = 'Baby Rogue';
$C[4041] = 'Baby Alchemist';
$C[4042] = 'Baby Bard';
$C[4043] = 'Baby Dancer';
$C[4045] = 'Super Baby';
$C[4046] = 'Taekwon';
$C[4047] = 'Star Gladiator';
$C[4049] = 'Soul Linker';
$number['class'] = 1;
echo $C[$number['class']];

 

Parse error: syntax error, unexpected '[', expecting ']' in /mnt/local/home/holoc/qq-ro.com/scripts/whosonline.php on line 29

Link to comment
Share on other sites

try making this

<td align=\"left\">$C[$row['class']]</td>

into this

<td align=\"left\">".$C[$row['class']]."</td>

 

Not that it should make a big difference, but it might.

 

if that doesn't work try this:

$gender = $row2['sex'];
$class = $row['class'];
		echo "	<tr>
			<td align=\"right\"><img src=\"../images/hairs/".$gender."/".$row['hair'].".gif\"></td>
			<td align=\"center\">".$row['name']."</td>
			<td> </td>
			<td align=\"left\">".$C[$class]."</td>
			<td> </td>
			<td> </td>
			<td align=\"left\">".$row['base_level']."/".$row['job_level']."</td>
			</tr>";
	}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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