Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > 4Story
You last visited: Today at 22:30

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

Advertisement



[Procedure] & [Help] TGetUserID by glossy

Discussion on [Procedure] & [Help] TGetUserID by glossy within the 4Story forum part of the MMORPGs category.

Reply
 
Old   #1
 
glossypvp's Avatar
 
elite*gold: 0
Join Date: Aug 2011
Posts: 662
Received Thanks: 658
Smile [Procedure] & [Help] TGetUserID by glossy

Hi,

When I was trying to create an itemshop for our 4story server, I needed to create a function which returns the userID if we know the username (szUserID).

Code:
ALTER PROCEDURE [dbo].[TGetUserID2]
@szUserID varchar(50)
AS
BEGIN
DECLARE @szRes varchar(50)
SET @szRes= (Select dwUserID FROM TGLOBAL_GSP.dbo.TACCOUNT where szUserID=@szUserID);
print @szRes
END
Code:
@szRes
will be the returned userID.

I need a little help, I would like to put this into PHP. I've tried two ways with no luck.
My code:.
PHP Code:
$_POST['Username']; 
stores the username as we know

PHP Code:
<?php
require_once("config.php");
$connect odbc_connect('Driver={SQL Server};Server='.$host.';'$user$pass);
$sql "Select dwUserID FROM TGLOBAL_GSP.dbo.TACCOUNT where szUserID='".$_POST['Username']."";
$r odbc_exec($connect,$sql);
print 
$r
?>
But usually it returns 0, or that:
Code:
Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\php\PEAR\Config.php on line 80

Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\php\PEAR\Config.php on line 166

Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\php\PEAR\Config\Container.php on line 111
Resource id #9
Logout
.

Can I get some help?
By the way use my code & procedure as you want, it's free
glossypvp is offline  
Old 02/17/2013, 08:33   #2
 
elite*gold: 0
Join Date: May 2010
Posts: 137
Received Thanks: 55
First of all you need some SQL injection measures. And then, you need to prepare the statement/connection. You do need to connect, and of course, close the connection. You could place all that inside a function, it would be easier for you to use it, and you can use it on other pages as well.

The function:
PHP Code:
<?php
function userid($username) {
    require_once(
"config.php");
    if (!
ctype_alnum($username)) {
        return 
0;
    }
    
$connect odbc_connect('Driver={SQL Server};Server=$host;'$user$pass);
    if (!
$connect) {
        return 
0;
    }
    
$sql "SELECT dwUserID FROM TGLOBAL_GSP.dbo.TACCOUNT WHERE szUserID=$username";
    
$prepared odbc_prepare($connect,$sql);
    
$r odbc_exec($prepared);
    
odbc_close($connection);
    return 
$r;
}
?>
The page:
PHP Code:
<?php
include("functions.php");
$userid userid($_POST['Username']);
if (!
$userid) {
    
// Error:
    // DB Error or SQL Injection Attempt
} else {
    
// Success:
    // Your normal page's code
}
?>
I think this would work, Im not 999% sure though.
acooarioom is offline  
Thanks
1 User
Old 02/17/2013, 08:42   #3




 
stotterer09's Avatar
 
elite*gold: 26
Join Date: Dec 2010
Posts: 2,628
Received Thanks: 1,816
I have a vb.net code which this you can get the userid if you like to have the code pm me
stotterer09 is offline  
Old 02/23/2013, 10:59   #4
 
glossypvp's Avatar
 
elite*gold: 0
Join Date: Aug 2011
Posts: 662
Received Thanks: 658
I've tried it, it's not working :S


Edit:
Finally I've done it!
PM me if you need the code.
glossypvp is offline  
Reply


Similar Threads Similar Threads
[Procedure] TCharCount by Glossy
04/21/2013 - 4Story - 5 Replies
Hi, I have just created a little MSSQL procedure with counts the characters on your server and display the value. Code: /* TCharCount procedure by GlossyPvP / Holy */ ALTER PROCEDURE . AS
Glossy Orb PSD
12/30/2011 - General Art - 0 Replies
Hallo Leute, ich werde ab jetzt immer mal PSD´s für euch zur Verfügung stellen, damit ihr sie euch angucken könnt. Eventuell nützlich für Lernzwecke - oder einfach benutzen. Heute ist ein Glossy Orb dran: http://img6.imagebanana.com/img/rf33fxq5/GlossyOr bkleineVorschau.jpg Ebenen in der PSD sollten alle gescheit benannt sein, Texturen etc. nur als Schnittmaske gesetzt sein. Die Grafik dürft ihr für alle Sachen benutzen - inkl. kommerzielle Zwecke.
Get a Glossy Userbar!
05/27/2010 - Grand Chase - 25 Replies
Get your own Glossy userbars ^.^ there are free get one +thank xD Lass! http://img94.imageshack.us/img94/8086/lassuserv.p ng Jin! http://img714.imageshack.us/img714/5589/jinuser.p ng Elesis! http://img196.imageshack.us/img196/535/elesisuser bar.png Seighart! http://img269.imageshack.us/img269/2047/seighartu ser.png



All times are GMT +1. The time now is 22:31.


Powered by vBulletin®
Copyright ©2000 - 2026, 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 ©2026 elitepvpers All Rights Reserved.