Raised This Month: $ Target: $400
 0% 

[SQLx] SelectHandle returns 0


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
P1raten
Senior Member
Join Date: Feb 2010
Old 01-26-2013 , 18:20   [SQLx] SelectHandle returns 0
Reply With Quote #1

Heya.

My SelectHandle is returning 0 for some reason.

I can't for the life of me figure out why. It's probably something simple, but I'm most likely too tired to see it.

PHP Code:
#include <amxmodx>
#include <sqlx>

// Ur Mysql Information
new Host[]    = "localhost";
new 
User[]    = "root";
new 
Pass[]    = "";
new 
Db[]      = "counterstrike";

new 
Handle:SqlConnection;
new 
Handle:g_SqlTuple;
new 
g_Error[512];

public 
plugin_init()
{
    
register_plugin"Plugin Name""0.1""P1raten" );
    
register_clcmd("say","CmdSay");
    
    
g_SqlTuple SQL_MakeDbTuple(Host,User,Pass,Db);

    new 
ErrorCode;
    
SqlConnection SQL_Connect(g_SqlTuple,ErrorCode,g_Error,charsmax(g_Error));

    if(
SqlConnection == Empty_Handle)
        
set_fail_state(g_Error);

    
SQL_FreeHandle(SqlConnection);
}

public 
CmdSay(id)
{
    new 
originPlayer[32];

    
get_user_name(idoriginPlayercharsmax(originPlayer));

    static 
Args[6][33],    singleArg[33];

    new 
Num read_argc();

    for(new 
Count 1Count <= NumCount++)
        
read_argv(CountArgs[Count 1], 32);

    
read_argv(2singleArg32);

    if(!
equali(Args[0], "/mysql"))
        return;
    else
        
SQL_ThreadQuery(g_SqlTuple"SelectHandle""SELECT * FROM tablename");
}

public 
SelectHandle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
    if(
FailState == TQUERY_CONNECT_FAILED)
        return 
set_fail_state("Could not connect to SQL database.")
    else if(
FailState == TQUERY_QUERY_FAILED)
        return 
set_fail_state("Query failed.")
   
    if(
Errcode)
        return 
log_amx("Error on query: %s",Error)
   
    new 
DataNum
    
while(SQL_MoreResults(Query))
    {
        
DataNum SQL_ReadResult(Query,0)
       
        
server_print("zomg, some data: %d",DataNum)
    
        
SQL_NextRow(Query)
    }
   
    return 
PLUGIN_CONTINUE

__________________
No salvation. Only madness.
P1raten is offline
 



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 20:31.


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