Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Shaiya > Shaiya Private Server > Shaiya PServer Development
You last visited: Today at 17:59

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



helping php iss users with mssql connect

Discussion on helping php iss users with mssql connect within the Shaiya PServer Development forum part of the Shaiya Private Server category.

Reply
 
Old 09/30/2011, 11:57   #31
 
Svinseladden's Avatar
 
elite*gold: 0
Join Date: Feb 2010
Posts: 675
Received Thanks: 240
i did so they work. but i tried this:

UPDATE dbo.Chars
SET LoginStatus = '0'
WHERE LoginStatus = 'NULL';

and i got this:

Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value 'NULL' to data type tinyint.

i can manualy do it. but 5000+ manualy is not a job i hope i have to do:-P
Svinseladden is offline  
Old 09/30/2011, 11:59   #32
 
RebeccaBlack's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 520
Received Thanks: 1,289
Silly Svinseladden (What does your name mean anyway?), LoginStatus is an Integer column, meaning ' ' isn't required. Just do:
Code:
UPDATE PS_GameData.dbo.Chars
SET LoginStatus=0
RebeccaBlack is offline  
Old 09/30/2011, 12:07   #33
 
Svinseladden's Avatar
 
elite*gold: 0
Join Date: Feb 2010
Posts: 675
Received Thanks: 240
ty worked. i own my name. svinseladden (norwegian) is well if you know a guy that always forget everything where ever he is and always just wonder in his own litle world. that's a svinsette gutt (also norwegian) so i was given that name and i see my self that way too. so svinseladden a guy that always wondering around forgetting what ha was suppose to do:-P
Svinseladden is offline  
Thanks
1 User
Old 09/30/2011, 12:10   #34
 
RebeccaBlack's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 520
Received Thanks: 1,289
Aha, thank you for that, was interesting to learn. :P
RebeccaBlack is offline  
Old 09/30/2011, 12:22   #35
 
Svinseladden's Avatar
 
elite*gold: 0
Join Date: Feb 2010
Posts: 675
Received Thanks: 240
i'm sorry to say but even after i have all to 0.

both 1 and 2 "procedure" are working i get:

Players online: ".$online." Human: ".$human." Elf: ".$elf." Vail: ".$vail." DeathEater: ".$nordein." "; @odbc_close($link); ?>

and i get nothing new error in the error log
Svinseladden is offline  
Old 09/30/2011, 12:30   #36
 
RebeccaBlack's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 520
Received Thanks: 1,289
I used everything in the folder I uploaded in my other thread, put a few character's login status as 1, and opened it, it all works for me.. can you explain further?
RebeccaBlack is offline  
Old 09/30/2011, 12:49   #37
 
Svinseladden's Avatar
 
elite*gold: 0
Join Date: Feb 2010
Posts: 675
Received Thanks: 240


still just get this.

and now i have 2 online or 1 onlinestatus..

i have this:

Quote:
<?
$host = '127.0.0.1';
$dbuser = 'Shaiya';
$dbpass = 'Shaiya123';
$database = 'PS_GameData';
//Connect to the database
$conn = @odbc_connect("Driver={SQL Server};Server=$host;Database=$database", $dbuser, $dbpass) or die("Database Connection Error!");

// check who's online
$result = @odbc_exec($conn,"SELECT Family FROM Chars WHERE LoginStatus=1",$link);

// initialize veriables
$online = @odbc_num_rows($result);
$human = $elf = $vail = $nordein = 0;

// fill variables with data (who's online)
while($row = @odbc_fetch_array($result))
{
if (@odbc_num_rows($result)==0) return;
switch($row['Family'])
{
case 0: $human++;break;
case 1: $elf++;break;
case 2: $vail++;break;
case 3: $nordein++;break;
};
};

// Print number of online players
print "<table style=\"border: 1px solid black;\">
<tr><td colspan=2>Players online: </td><td>".$online."</td></tr>
<tr><td>Human: </td><td>".$human."</td></tr>
<tr><td>Elf: </td><td>".$elf."</td></tr>
<tr><td>Vail: </td><td>".$vail."</td></tr>
<tr><td>DeathEater: </td><td>".$nordein."</td></tr>
</table>";

@odbc_close($link);

?>
well changed everything to my loggin that is he he

even if i change loggin to a wrong one i still get the same + with a wrong connect (username and password i still don't get an error in the logg)
Svinseladden is offline  
Old 09/30/2011, 12:54   #38
 
RebeccaBlack's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 520
Received Thanks: 1,289
Remove all the @ and see if they throw an error..
RebeccaBlack is offline  
Old 09/30/2011, 12:57   #39
 
Svinseladden's Avatar
 
elite*gold: 0
Join Date: Feb 2010
Posts: 675
Received Thanks: 240
still the same no error

well if i ad: <?php
//Connection configuration to the top it works even without the @ too
Svinseladden is offline  
Thanks
1 User
Old 09/30/2011, 13:04   #40
 
RebeccaBlack's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 520
Received Thanks: 1,289
..**** I forgot to add that to the original. I owe you so many thanks for finding bugs in all the scripts I uploading >_>
RebeccaBlack is offline  
Old 09/30/2011, 13:13   #41
 
Svinseladden's Avatar
 
elite*gold: 0
Join Date: Feb 2010
Posts: 675
Received Thanks: 240
LOL i owe you more. and btw. elite pvpers have there own php out. and under tnelis. i have this:

adding them to this post as attachment. if you can this would be a good deal for gm's out there..
Attached Files
File Type: rar tnelis.rar (495.8 KB, 39 views)
Svinseladden is offline  
Old 09/30/2011, 13:28   #42
 
RebeccaBlack's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 520
Received Thanks: 1,289
tnelis isn't so different from RebeccaBlack

I'll redo those tomorrow, if I remember. Too tired right now.
RebeccaBlack is offline  
Thanks
1 User
Old 09/30/2011, 15:23   #43
 
Svinseladden's Avatar
 
elite*gold: 0
Join Date: Feb 2010
Posts: 675
Received Thanks: 240
ty:-)
Svinseladden is offline  
Old 10/04/2011, 15:01   #44
 
Svinseladden's Avatar
 
elite*gold: 0
Join Date: Feb 2010
Posts: 675
Received Thanks: 240
Quote:
<?php
function mssql_escape_string($data)
{
if (!isset($data) or empty($data))
return '';
if (is_numeric($data))
return $data;
$non_displayables = array('/%0[0-8bcef]/', // url encoded 00-08, 11, 12, 14, 15
'/%1[0-9a-f]/', // url encoded 16-31
'/[\x00-\x08]/', // 00-08
'/\x0b/', // 11
'/\x0c/', // 12
'/[\x0e-\x1f]/'); // 14-31
foreach ($non_displayables as $regex)
$data = preg_replace($regex, '', $data);
$data = str_replace("'", "''", $data);
return $data;
}

$host = '127.0.0.1';
$dbuser = 'Shaiya';
$dbpass = 'Shaiya123';

$class = array(0 => 'Warrior', 1 => 'Guardian', 2 => 'Assasin', 3 => 'Hunter', 4 => 'Pagan', 5 => 'Oracle', 6 => 'Fighter', 7 => 'Defender', 8 => 'Ranger', 9 => 'Archer', 10 => 'Mage', 11 => 'Priest');

$conn = @odbc_connect("Driver={SQL Server};Server=$host;", $dbuser, $dbpass) or die("Database Connection Error!");
$UserID = isset($_POST['username']) ? mssql_escape_string(trim($_POST['username'])) : '';
$Pass = isset($_POST['password']) ? mssql_escape_string(trim($_POST['password'])) : '';
$Char = isset($_POST['char']) ? mssql_escape_string(trim($_POST['char'])) : '';

if (isset($_POST['submit'])) {
if (strlen($UserID) < 1)
die("User Name too short");
if (strlen($Pass) < 1)
die("Password too short.");

$res = odbc_exec($conn, "SELECT * FROM [PS_UserData].[dbo].[Users_Master] WHERE UserID = '" . $UserID . "' AND Pw = '" . $Pass . "'");

if (odbc_num_rows($res) == 0) {
die("Username/Password is incorrect");
} else {
$res2 = odbc_exec($conn,"SELECT umg.Country, c.Family, c.CharName, c.CharID, c.Job, c.Level
FROM [PS_GameData].[dbo].[UserMaxGrow] AS umg
INNER JOIN [PS_GameData].[dbo].[Chars] AS c ON umg.UserUID = c.UserUID
WHERE c.UserID = '" . $UserID . "' AND c.Del=1");

if (odbc_num_rows($res2) == 0) {
echo "Account does not contain any dead characters.";
} else {
echo "<form action=\"" . $_SERVER['PHP_SELF'] . "\" method=\"POST\">Select toon to resurrect :<br />
<input type=\"hidden\" name=\"username\" value=\"" . $UserID . "\">
<table cellspacing=1 cellpadding=2 border=1 style=\"border-style:hidden;\">
<tr><td>Select</td><td>CharName</td><td>Class</td><td>Level</td></tr>";
while ($chars = odbc_fetch_array($res2)) {
if ($chars['Country'] == 0) {
if ($chars['Family'] == 0 || $chars['Family'] == 1) {
echo "<tr>";
echo "<td><input type=\"radio\" name =\"char\" value=\"" . $chars['CharName'] . "," . $chars['CharID'] . "\"></td>";
echo "<td>" . $chars['CharName'] . "</td><td>" . $class[$chars['Job'] + 6] . "</td>";
echo "<td>" . $chars['Level'] . "</td>";
echo "</tr>";
}
} elseif ($chars['Country'] == 1) {
if ($chars['Family'] == 2 || $chars['Family'] == 3) {
echo "<tr>";
echo "<td><input type=\"radio\" name =\"char\" value=\"" . $chars['CharName'] . "," . $chars['CharID'] . "\"></td>";
echo "<td>" . $chars['CharName'] . "</td><td>" . $class[$chars['Job']] . "</td>";
echo "<td>" . $chars['Level'] . "</td>";
echo "</tr>";
}
}
}
echo "</table><input type=\"submit\" value=\"Submit\" name=\"submit2\" /></form>";
}
}
} elseif (isset($_POST['submit2'])) {
$slot = -1;
$res1 = odbc_exec($conn, "
SELECT MIN(Slots.Slot) AS OpenSlot FROM
(SELECT 0 AS Slot UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) AS Slots
LEFT JOIN
(SELECT c.Slot
FROM PS_UserData.dbo.Users_Master AS um
INNER JOIN PS_GameData.dbo.Chars AS c ON c.UserUID = um.UserUID
WHERE um.UserID = '" . $UserID . "'
AND c.Del = 0) AS Chars ON Chars.Slot = Slots.Slot
WHERE Chars.Slot IS NULL");
$slot = odbc_fetch_array($res1);
$toon2 = explode(',', $Char);
if ($slot['OpenSlot'] > -1 && $slot['OpenSlot'] < 5) {
odbc_exec($conn, "UPDATE PS_GameData.dbo.Chars SET Del=0, Slot=".$slot['OpenSlot'].", Map=42, PosX=63 , PosZ=57, DeleteDate=NULL WHERE CharID = $toon2[1]");
echo "Successfully resurrected <br /> Login = " . $UserID . "<br />Slot = " . ($slot['OpenSlot'] + 1) . "<br />Char = $toon2[0]";
} else
echo "No slots avaliable";
} else {
?>
<html>
<head>
<title>Character Ressurection</title></head>
<body>
<form action="<?php
echo $_SERVER['PHP_SELF'];
?>" method="POST">
<fieldset style="font:100% trebuchet ms;width:100px;">
<legend >Resurrection Form </legend>
<font face="Trebuchet MS">
<table>
<tr>
<font size=1><i>*Toon will be resurrected in an avaliable free slot.</i></font>
</tr>
<tr>
<td>Account Login:</td><td> <input type="text" name="username" maxlength=20/></td>
</tr>
<tr>
<td>Account Password:</td><td><input type="password" name="password" maxlength=20/></td>
</tr>
</font>
</table>
<input type="submit" value="Submit" name="submit" />
</fieldset>
</form>
</body>
</html>
<?php
}
?>
this seem to work. but even if it say it's ressurected it's not. and no error code. any idea why?

tested it again. now it works. liiks like some work but not all. can't use caps letters it seems. all change to small letters even if i try with big. chould this be the problem?

becouse some work but other's don't i realy don't understand this..
Svinseladden is offline  
Old 10/20/2011, 09:57   #45
 
Svinseladden's Avatar
 
elite*gold: 0
Join Date: Feb 2010
Posts: 675
Received Thanks: 240
Quote:
Originally Posted by RebeccaBlack View Post
My bad! I spotted the error immediately.
PHP Code:
<?php
  
function mssql_escape_string($data)
  {
      if (!isset(
$data) or empty($data))
          return 
'';
      if (
is_numeric($data))
          return 
$data;
      
$non_displayables = array('/%0[0-8bcef]/'// url encoded 00-08, 11, 12, 14, 15
      
'/%1[0-9a-f]/'// url encoded 16-31
      
'/[\x00-\x08]/'// 00-08
      
'/\x0b/'// 11
      
'/\x0c/'// 12
      
'/[\x0e-\x1f]/'); // 14-31
      
foreach ($non_displayables as $regex)
          
$data preg_replace($regex''$data);
      
$data str_replace("'""''"$data);
      return 
$data;
  }
  
  
$host '127.0.0.1';
  
$dbuser 'Shaiya';
  
$dbpass 'Shaiya123';
  
  
$class = array(=> 'Warrior'=> 'Guardian'=> 'Assasin'=> 'Hunter'=> 'Pagan'=> 'Oracle'=> 'Fighter'=> 'Defender'=> 'Ranger'=> 'Archer'10 => 'Mage'11 => 'Priest');
  
  
$conn = @odbc_connect("Driver={SQL Server};Server=$host;"$dbuser$dbpass) or die("Database Connection Error!");
  
$UserID = isset($_POST['username']) ? mssql_escape_string(trim($_POST['username'])) : '';
  
$Pass = isset($_POST['password']) ? mssql_escape_string(trim($_POST['password'])) : '';
  
$Char = isset($_POST['char']) ? mssql_escape_string(trim($_POST['char'])) : '';
  
  if (isset(
$_POST['submit'])) {
      if (
strlen($UserID) < 1)
          die(
"User Name too short");
      if (
strlen($Pass) < 1)
          die(
"Password too short.");
      
      
$res odbc_exec($conn"SELECT * FROM [PS_UserData].[dbo].[Users_Master] WHERE UserID = '" $UserID "' AND Pw = '" $Pass "'"); 
      
      if (
odbc_num_rows($res) == 0) {
          die(
"Username/Password is incorrect");
      } else {
          
$res2 odbc_exec($conn,"SELECT umg.Country, c.Family, c.CharName, c.CharID, c.Job, c.Level
FROM [PS_GameData].[dbo].[UserMaxGrow] AS umg 
INNER JOIN [PS_GameData].[dbo].[Chars] AS c ON umg.UserUID = c.UserUID
WHERE c.UserID = '" 
$UserID "' AND c.Del=1");
          
          if (
odbc_num_rows($res2) == 0) {
              echo 
"Account does not contain any dead characters.";
          } else {
              echo 
"<form action=\"" $_SERVER['PHP_SELF'] . "\" method=\"POST\">Select toon to resurrect :<br />
<input type=\"hidden\" name=\"username\" value=\"" 
$UserID "\">
<table cellspacing=1 cellpadding=2 border=1 style=\"border-style:hidden;\">
<tr><td>Select</td><td>CharName</td><td>Class</td><td>Level</td></tr>"
;
              while (
$chars odbc_fetch_array($res2)) {
                  if (
$chars['Country'] == 0) {
                      if (
$chars['Family'] == || $chars['Family'] == 1) {
                          echo 
"<tr>";
                          echo 
"<td><input type=\"radio\" name =\"char\" value=\"" $chars['CharName'] . "," $chars['CharID'] . "\"></td>";
                          echo 
"<td>" $chars['CharName'] . "</td><td>" $class[$chars['Job'] + 6] . "</td>";
                          echo 
"<td>" $chars['Level'] . "</td>";
                          echo 
"</tr>";
                      }
                  } elseif (
$chars['Country'] == 1) {
                      if (
$chars['Family'] == || $chars['Family'] == 3) {
                          echo 
"<tr>";
                          echo 
"<td><input type=\"radio\" name =\"char\" value=\"" $chars['CharName'] . "," $chars['CharID'] . "\"></td>";
                          echo 
"<td>" $chars['CharName'] . "</td><td>" $class[$chars['Job']] . "</td>";
                          echo 
"<td>" $chars['Level'] . "</td>";
                          echo 
"</tr>";
                      }
                  }
              }
              echo 
"</table><input type=\"submit\" value=\"Submit\" name=\"submit2\" /></form>";
          }
      }
  } elseif (isset(
$_POST['submit2'])) {
      
$slot = -1;
      
$res1 odbc_exec($conn"
SELECT MIN(Slots.Slot) AS OpenSlot FROM
(SELECT 0 AS Slot UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) AS Slots
LEFT JOIN
(SELECT c.Slot
FROM PS_UserData.dbo.Users_Master AS um
INNER JOIN PS_GameData.dbo.Chars AS c ON c.UserUID = um.UserUID
WHERE um.UserID = '" 
$UserID "'
AND c.Del = 0) AS Chars ON Chars.Slot = Slots.Slot
WHERE Chars.Slot IS NULL"
);
      
$slot odbc_fetch_array($res1);
      
$toon2 explode(','$Char);
      if (
$slot['OpenSlot'] > -&& $slot['OpenSlot'] < 5) {
          
odbc_exec($conn"UPDATE PS_GameData.dbo.Chars SET Del=0, Slot=".$slot['OpenSlot'].", Map=42, PosX=63 , PosZ=57, DeleteDate=NULL WHERE CharID = $toon2[1]");
          echo 
"Successfully resurrected <br /> Login = " $UserID "<br />Slot = " . ($slot['OpenSlot'] + 1) . "<br />Char = $toon2[0]";
      } else
          echo 
"No slots avaliable";
  } else {
?>
<html>
<head>
<title>Character Ressurection</title></head>
<body>
<form action="<?php
      
echo $_SERVER['PHP_SELF'];
?>" method="POST">
<fieldset style="font:100% trebuchet ms;width:100px;">
<legend >Resurrection Form </legend>
<font face="Trebuchet MS">
<table>
<tr>
<font size=1><i>*Toon will be resurrected in an avaliable free slot.</i></font>
</tr>
<tr>
<td>Account Login:</td><td>  <input type="text" name="username" maxlength=20/></td>
</tr>
<tr>
<td>Account Password:</td><td><input type="password" name="password" maxlength=20/></td>
</tr>
</font>
</table>
<input type="submit" value="Submit" name="submit" />
</fieldset>
</form>
</body>
</html>
<?php
  
}
?>
I tested part of it on my desktop, and it loaded correctly, however I didn't test much further. Let me know the results. ^^
found an error rebecca. this alows faction change. i now have darkies in the light world and the other way around. any way that this could be not able to del all your chars. then change faction then ress all your toons in the new faction?
Svinseladden is offline  
Reply


Similar Threads Similar Threads
MSSQL-connect Problem
07/02/2011 - Flyff Private Server - 0 Replies
Ich versuche seit einer Stunde Treachery CS-Shop zum laufen zu kriegen, aber ich schaffe es einfach nicht das PHP sich endlich mal meinem Willen beugt und sich mit meiner DB verbindet... Ich gebe in die config.php datei brav meine Daten ein, allerdings will es trotzdem nicht klappen... http://img18.imageshack.us/img18/2105/mssql.png http://img220.imageshack.us/img220/8788/configr.p ng http://img31.imageshack.us/img31/7397/resultata.p ng Wäre echt nett, wenn mir jemand einen Tipp geben...
[NOTICE] Unable to connect to MSSQL server using XAMPP
12/06/2010 - Dekaron Private Server - 0 Replies
Hi, i would like to notice that if you use XAMPP and install Apache as Service it happened to me for some reason Error: you might have a ERROR "Unable to connect to server ..." if you try to load a page that contains a mssql connection This seems to happen on XAMPP for windows 1.7.3
Giving a 78 2 hand on Posidon for helping me connect my xbox360 to pc
11/29/2009 - Silkroad Online Trading - 2 Replies
Hey all iam giving a 78 2 hand sword on posidon for anyone can help me connect xbox 360 to my pc windows i guess its the best offer ;) my msn: [email protected] my skype: maged.edward
[Helping Topic] 24/7 Helping Services!
08/27/2008 - EO PServer Hosting - 31 Replies
stucked on anything while setuping your server? post your problem here and you will get answer as fast as possible better than spamming with posts :cool: first of all try reading Ahmedpotop's Pserver All thing guide. if your couldn't solve it out post your problem down here ""That includes PHP rankings pages / registrations pages / Status pages""



All times are GMT +1. The time now is 18:00.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.