AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SQLx] SelectHandle returns 0 (https://forums.alliedmods.net/showthread.php?t=206858)

P1raten 01-26-2013 18:20

[SQLx] SelectHandle returns 0
 
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


:roll:

michal123 01-27-2013 02:57

Re: [SQLx] SelectHandle returns 0
 
You haven't create table in database. You want select something from this table, but this table doesn't exist.


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

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