Raised This Month: $ Target: $400
 0% 

SQL Column Issue.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 01-19-2007 , 13:17   SQL Column Issue.
Reply With Quote #1

I have studied Hawk's little tutorial on the new SQLX module and it's function and seem to be having a little trouble when it comes to retrieving data column by column.


Code:
#include <amxmodx> #include <amxmisc> #include <sqlx> #include <EvoRP> //CVARS #define HUD_1_X "evorp_hud_1_x" #define HUD_1_Y "evorp_hud_1_y" #define HUD_1_RED "evorp_hud_1_red" #define HUD_1_BLU "evorp_hud_1_blue" #define HUD_1_GRE "evorp_hud_1_green" #define HUD_2_X "evorp_hud_2_x" #define HUD_2_Y "evorp_hud_2_y" #define HUD_2_RED "evorp_hud_2_red" #define HUD_2_BLU "evorp_hud_2_blue" #define HUD_2_GRE "evorp_hud_2_green" //SQL Vars new Handle:g_SqlTuple new Handle:Query new Handle:SqlConnection new g_Error[512] new g_Query[32][512] //Necessary Vars new g_SteamIDS[32][32] //Data Vars new g_Bank[32] = 0 new g_Wallet[32] = 0 public plugin_init() {     register_plugin("EvoRP - Hud","1.0","Remo Williams")         //CVARS     register_cvar(HUD_1_X,"-1.9")     register_cvar(HUD_1_Y,"0.0")     register_cvar(HUD_1_RED,"0")     register_cvar(HUD_1_BLU,"190")     register_cvar(HUD_1_GRE,"255")     register_cvar(HUD_2_X,"1.0")     register_cvar(HUD_2_Y,"0.0")     register_cvar(HUD_2_RED,"0")     register_cvar(HUD_2_BLU,"190")     register_cvar(HUD_2_GRE,"255") } public client_authorized(id) {     set_task(5.0,"update_data",id,_,_,"b")     get_user_authid(id,g_SteamIDS[id],31) } public client_disconnect(id) {     remove_task(id)     reset_data(id) } public update_data(id) {       g_Query[id][0] = 0     format(g_Query[id],511,"SELECT * FROM users WHERE SteamID=^"%s^"",g_SteamIDS[id])     new data[10][32]     retrieve_data(g_Query[id],data) } stock retrieve_data(query[]="",output[][32]) {     g_SqlTuple = e_core_get_sql_handle()         server_print(query)         new ErrorCode         SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)     if(g_SqlTuple == Empty_Handle)         set_fail_state(g_Error)         Query = SQL_PrepareQuery(SqlConnection,query)         if(!SQL_Execute(Query))     {         SQL_QueryError(Query,g_Error,511)         set_fail_state(g_Error)     }         new i = 0     while(SQL_MoreResults(Query))     {         while(SQL_NumColumns(Query))         {             SQL_ReadResult(Query,i,output[i],31)             server_print("Found data: %s",output[i])             i++         }         SQL_NextRow(Query)     }     SQL_FreeHandle(Query)     SQL_FreeHandle(SqlConnection) } public reset_data(id) {     g_Bank[id] = 0     g_Wallet[id] = 0     g_SteamIDS[id][0] = 0     g_Query[id][0] = 0 }

Now the thing is, there are only four columns in the user's table.
The server retrieves all of the data properly, but it reads me an error message "[MySQL] Invalid Column: 4" from line 95.
Now the thing is, I thought the while() loop was only supposed to go through what is being retrieved only, and not going past that.
This all is still a bit vague to me and was wondering if anyone would take the time out to assist me here.

Thanks in advance.


Main Plugin:
Code:
#include <amxmodx> #include <amxmisc> #include <sqlx> #include <EvoRP> //CVARS #define SQL_HOST "evorp_host" #define SQL_USER "evorp_user" #define SQL_PASS "evorp_pass" #define SQL_DB "evorp_db" new Handle:g_SqlTuple new Handle:SqlConnection new g_Error[512] public plugin_init() {     register_plugin("EvoRP - Core","1.0","Remo Williams")         register_cvar(SQL_HOST,"localhost",FCVAR_PROTECTED)     register_cvar(SQL_USER,"root",FCVAR_PROTECTED)     register_cvar(SQL_PASS,"",FCVAR_PROTECTED)     register_cvar(SQL_DB,"EvoRP",FCVAR_PROTECTED)         set_task(5.0,"sql_test")         server_cmd("exec addons/amxmodx/configs/EvoRP/EvoRP_Config.cfg") } public plugin_natives() {     register_native("e_core_get_sql_handle","get_sql_handle") } public sql_test() {       new Host[64],User[64],Pass[64],Db[64]     get_cvar_string(SQL_HOST,Host,63)     get_cvar_string(SQL_USER,User,63)     get_cvar_string(SQL_PASS,Pass,63)     get_cvar_string(SQL_DB,Db,63)         g_SqlTuple = SQL_MakeDbTuple(Host,User,Pass,Db)         new ErrorCode     SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)         if(SqlConnection == Empty_Handle)         set_fail_state(g_Error)     server_print("______________________________^n")     server_print("Connection Information:")     server_print(" » Host: %s",Host)     server_print(" » User: %s",User)     server_print(" » Pass: ******")     server_print(" » DB: %s",Db)         if(ErrorCode)     {         server_print("^n{EvoRP} Connection: Error")         server_print("{EvoRP} Connection: %s",g_Error)     }     else server_print("^n{EvoRP} Database: Successful")     server_print("______________________________")     g_Error[0] = 0 }     public get_sql_handle() {     return _:g_SqlTuple } public plugin_end() {     //SQL_FreeHandle(g_SqlTuple) }
__________________


Last edited by mysticssjgoku4; 01-19-2007 at 13:22.
mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
 



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 22:19.


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