Raised This Month: $ Target: $400
 0% 

error in admin.amxx


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sutar
Senior Member
Join Date: Sep 2010
Old 09-27-2012 , 13:38   error in admin.amxx
Reply With Quote #1

Hi all, so I wrote this script:

Code:
query = SQL_PrepareQuery(sql, "SELECT ...", ip, port)
	
	if(!SQL_Execute(query))
	{
		SQL_QueryError(query, error, 127)
		server_print("SQL error: can't load admins: '%s'!", error)
	} else if(!SQL_NumResults(query)) {
		server_print("No admins found on this server...")
	} else {
		new szFlags[2], szAccess[25]
		
		g_aNum = 0

		while(SQL_MoreResults(query))
		{
			SQL_ReadResult(query, 1, g_aName[g_aNum], 31)
			SQL_ReadResult(query, 2, g_aPassword[g_aNum], 15)
			SQL_ReadResult(query, 3, szAccess, 24)
			SQL_ReadResult(query, 4, szFlags, 1)
			SQL_ReadResult(query, 5, g_aDate[g_aNum], 11)
			SQL_ReadResult(query, 6, g_aLife[g_aNum], 11)
			
			g_aAccess[g_aNum] = read_flags(szAccess)
			g_aFlags[g_aNum] = read_flags(szFlags)
			
			++g_aNum
			SQL_NextRow(query)
		}
error in line SQL_ReadResult(query, 6, g_aLife[g_aNum], 11)

Here he writes:
Code:
L 09/27/2012 - 20:33:55: [MySQL] Invalid column: 6
L 09/27/2012 - 20:33:55: [AMXX] Displaying debug trace (plugin "admin.amxx")
L 09/27/2012 - 20:33:55: [AMXX] Run time error 10: native error (native "SQL_ReadResult")
L 09/27/2012 - 20:33:55: [AMXX]    [0] admin.sma::adminSql (line 88)
L 09/27/2012 - 20:33:55: [AMXX]    [1] admin.sma::cmdReload (line 109)
How to fix it?

Last edited by Sutar; 09-27-2012 at 13:39.
Sutar is offline
matsi
Thinkosaur
Join Date: Sep 2006
Old 09-27-2012 , 14:20   Re: error in admin.amxx
Reply With Quote #2

You have the answer in the error. "Invalid column". You're trying to read results from column that doesn't exist, make sure its created correctly.
__________________

Accepting all kinds of requests via private message.
matsi is offline
Sutar
Senior Member
Join Date: Sep 2010
Old 09-28-2012 , 02:20   Re: error in admin.amxx
Reply With Quote #3

So I did this:
Code:
		new qcolAuth = SQL_FieldNameToNum(query, "username")
		new qcolPass = SQL_FieldNameToNum(query, "password")
		new qcolAccess = SQL_FieldNameToNum(query, "access")
		new qcolFlags = SQL_FieldNameToNum(query, "flags")
		new qcolDate = SQL_FieldNameToNum(query, "adddate")
		new qcolTime = SQL_FieldNameToNum(query, "timelife")
		
		server_print("SQL qcolAuth %d", qcolAuth)
		server_print("SQL qcolPass %d", qcolPass)
		server_print("SQL qcolAccess %d", qcolAccess)
		server_print("SQL qcolFlags %d", qcolFlags)
		server_print("SQL qcolDate %d", qcolDate)
		server_print("SQL qcolTime %d", qcolTime)
		
		while(SQL_MoreResults(query))
		{
			SQL_ReadResult(query, qcolAuth, g_aName[g_aNum], 31)
			SQL_ReadResult(query, qcolPass, g_aPassword[g_aNum], 15)
			SQL_ReadResult(query, qcolAccess, szAccess, 24)
			SQL_ReadResult(query, qcolFlags, szFlags, 1)
			SQL_ReadResult(query, qcolDate, g_aDate[g_aNum], 11)
			SQL_ReadResult(query, qcolTime, g_aLife[g_aNum], 11)
			
			g_aAccess[g_aNum] = read_flags(szAccess)
			g_aFlags[g_aNum] = read_flags(szFlags)
			
			++g_aNum
			SQL_NextRow(query)
		}
And I found:
Quote:
qcolAuth 0
SQL qcolPass 1
SQL qcolAccess 2
SQL qcolFlags 3
SQL qcolDate 4
SQL qcolTime 5
MySQL reads a field from 0?

Last edited by Sutar; 09-28-2012 at 02:22.
Sutar is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 09-28-2012 , 02:25   Re: error in admin.amxx
Reply With Quote #4

SQLx numbers the columns starting at 0, yes
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Reply


Thread Tools
Display Modes

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:21.


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