Raised This Month: $ Target: $400
 0% 

SQLx issue


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Min2liz
AlliedModders Donor
Join Date: Feb 2008
Location: Street
Old 03-03-2010 , 06:32   SQLx issue
Reply With Quote #1

Hi,

I'm new on amxx scripting so please don't laugh ;)

Here is a code:

Code:
                new qcolAuth = SQL_FieldNameToNum(Query, "user")
		new qcolPass = SQL_FieldNameToNum(Query, "password")
		new qcolAccess = SQL_FieldNameToNum(Query, "access")
		new qcolPoints = SQL_FieldNameToNum(Query, "points")
		
		new AuthData[44]
		new Password[44]
		new Access[32]
		new Float:Points
		
		SQL_ReadResult(Query, qcolAuth, AuthData, sizeof(AuthData)-1)
		SQL_ReadResult(Query, qcolPass, Password, sizeof(Password)-1)
		SQL_ReadResult(Query, qcolAccess, Access, sizeof(Access)-1)
		SQL_ReadResult(Query, qcolPoints, Points,0)
		
		
		
		get_user_info(id, "_pw", pass, 31)
		
		// netinka pass
		if (!equal(Password,pass)) {
			server_cmd("kick #%d Wrong pass", get_user_userid(id))
		}
		// Registruotas
		else {
			PlayerXP[id] = Points
			PlayerCon[id] = true
			log_amx("SELECT * FROM %s WHERE `user`='%s'",SQL_TABLE,name)
			log_amx("%s points: %i",AuthData,Points)
		}
Everything looks working, but Points all the time I get 0. In DB i write for example: 15, but after this I still get 0. No errors, no warnings don't get.


Sorry for bad english...
Min2liz is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 03-03-2010 , 08:40   Re: SQLx issue
Reply With Quote #2

Try
Points = SQL_ReadResult( Query, qcolPoints );
__________________
xPaw is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-03-2010 , 09:21   Re: SQLx issue
Reply With Quote #3

Quote:
Originally Posted by xPaw View Post
Try
Points = SQL_ReadResult( Query, qcolPoints );
This should do the trick. You are attempting to retrieve an integer and the function thinks you want a string so you are getting no result.

http://www.amxmodx.org/funcwiki.php?go=func&id=1105
Code:
SQL_ReadResult ( Handle:query, column, {Float,_}:... )

Retrieves the current result.
A successful query starts at the first result, so you should not call SQL_NextRow() first.

Passing no extra params - return int
Passing one extra param - return float in 1st extra arg
Passing two extra params - return string in 1st arg, max length in 2nd
__________________
Bugsy is offline
Min2liz
AlliedModders Donor
Join Date: Feb 2008
Location: Street
Old 03-03-2010 , 20:05   Re: SQLx issue
Reply With Quote #4

Thanks a lot guys. Works fine now
Min2liz is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:35.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode