AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problems with SQLx Query... (https://forums.alliedmods.net/showthread.php?t=49669)

Rixorster 01-10-2007 14:00

Problems with SQLx Query...
 
Well, meh function is like this:
Code:
public sqlx_test(id) {     new authid[32]     get_user_authid(id,authid,31)     new Handle:Query = SQL_PrepareQuery(g_SqlConnection,"SELECT job FROM accounts WHERE steamid='%s'",authid);     SQL_Execute(Query)     if(!SQL_Execute(Query))     {         // if there were any problems         SQL_QueryError(Query,g_Error,511)         set_fail_state(g_Error)     }     StoreOther = SQL_ReadResult(Query, 0)     client_print(id,print_chat,"[SQLx Test] Found data : %d ",StoreOther)     SQL_FreeHandle(Query) }
It says something like(Not sure but): [MySQL] No result from this query.
What's wrong with it?
Oh, and meh plugin_init is:
Code:
public plugin_init() {     // Registering     register_plugin("Items 2.0", "0.1b", "Rixorster")     // Console Commands     register_concmd("item_aidkit","item_aidkit")     register_concmd("item_emergencykit","item_emergencykit")     register_concmd("item_tazer","item_tazer")     register_concmd("item_lockpick","item_lockpick")     register_concmd("sqlx_test","sqlx_test")     // Client Commands     register_clcmd("say /trigger","Handle_Use")     register_clcmd("say /jail","Handle_Jail")     // Cvars     register_cvar("hrp_sql_host","127.0.0.1")     register_cvar("hrp_sql_user","root")     register_cvar("hrp_sql_pass","lollero")     register_cvar("hrp_sql_db","economy")     // SQLx     new host[64], user[64], pass[64], db[64], error[255];     get_cvar_string( "hrp_sql_host", host, 63 );     get_cvar_string( "hrp_sql_user", user, 63 );     get_cvar_string( "hrp_sql_pass", pass, 63 );     get_cvar_string( "hrp_sql_db", db, 63 );         g_SqlTuple = SQL_MakeDbTuple(host,user,pass,db);     new errorcode     g_SqlConnection=SQL_Connect(g_SqlTuple,errorcode,error,254);     if (!g_SqlConnection)     {         console_print(0,"[HRPi] Server cannot connect to database.")         console_print(0,"[HRPi] Error(%d): %s",errorcode,error)         return     }     console_print(0,"[HRPi] SQLx Connection Succesfull!") }

lunarwolfx 01-10-2007 17:21

Re: Problems with SQLx Query...
 
Here is your problem.

Code:
    new Handle:Query = SQL_PrepareQuery(g_SqlConnection,"SELECT job FROM accounts WHERE steamid='%s'",authid);

It's SELECT * job

Bad_Bud 01-10-2007 18:05

Re: Problems with SQLx Query...
 
What does the * do?

teame06 01-10-2007 20:45

Re: Problems with SQLx Query...
 
Code:
    SQL_Execute(Query)     if(!SQL_Execute(Query))

You have two SQL_Execute here too. You should remove one of them.

Code:

SELECT * FROM ...
^--- This means select all columns FROM the table.

Code:

SELECT `job` FROM ...
^---This means only select the job column from the table.

Don't use SELECT * job. I believe that incorrect.

Other than that I do not see anything wrong with the code or the row for that steamid does not exist

Bad_Bud 01-10-2007 22:40

Re: Problems with SQLx Query...
 
Would SELECT * FROM tablename WHERE blah='blah'

Give you all of the columns, or would it give you all of the columns except for blah?

lunarwolfx 01-10-2007 22:45

Re: Problems with SQLx Query...
 
bleh, you're right, it's not SELECT * job, I kinda jumped the gun on that one.

@bad_bud, that would give you the columns in which the blah column is equal to "blah"


All times are GMT -4. The time now is 22:20.

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