AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   sql results (https://forums.alliedmods.net/showthread.php?t=233818)

yoni279 01-20-2014 14:33

sql results
 
hey i'm doing this:
copy(g_Cache,511,"SELECT ip FROM mods WHERE ID = 1")
SQL_ThreadQuery(g_SqlTuple,"SelectHandle",g_C ache)
and the results i get its:
10
and in the table its: 10.0.0.1:27015
thats is the public

PHP Code:

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)
        
ColorChat(0NORMAL"%d"DataNum)
        
SQL_NextRow(Query)
    }
   
    return 
PLUGIN_CONTINUE


how can i do i get all the ip?
10.0.0.1:27015?

kasu007 01-21-2014 05:05

Re: sql results
 
Well 1st your problem is,
1) your variable is integer
2) your reading datanum as you read "integer"
3) your outputing your variable as integer aswell

but you should be doing as string

PHP Code:

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[32]
    while(
SQL_MoreResults(Query))
    {
        
SQL_ReadResult(Query0DataNum31)
        
ColorChat(0NORMAL"%s"DataNum)
        
SQL_NextRow(Query)
    }
   
    return 
PLUGIN_CONTINUE


this should work


All times are GMT -4. The time now is 10:11.

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