Raised This Month: $ Target: $400
 0% 

sqlx my code wrong ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DaniDin
Member
Join Date: Oct 2008
Old 12-26-2008 , 10:15   sqlx my code wrong ?
Reply With Quote #1

hi i have db and table with the name "tbname" and column "name"
when i do this
PHP Code:
public client_disconnect(id)
    
SQL_ThreadQuery(g_SqlTuple,"SelectHandle","SELECT name FROM tbname WHERE id='1'")

    
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_cmd("amx_say your name is %d ",DataNum)
    
        
SQL_NextRow(Query)
    }
   
    return 
PLUGIN_CONTINUE

i get like this : your name is 0
but i have the name "loler"
and i want that print this "Your name is loler"
DaniDin is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 12-26-2008 , 10:17   Re: sqlx my code wrong ?
Reply With Quote #2

Code:
server_cmd("amx_say your name is %d ",DataNum)
How that could even print a string?
SnoW is offline
Send a message via MSN to SnoW
DaniDin
Member
Join Date: Oct 2008
Old 12-26-2008 , 10:21   Re: sqlx my code wrong ?
Reply With Quote #3

><
so ? lol
i try %s it's not work too
DaniDin is offline
DaniDin
Member
Join Date: Oct 2008
Old 12-26-2008 , 10:24   Re: sqlx my code wrong ?
Reply With Quote #4

when i do %s it's print null ("")
DaniDin is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 12-26-2008 , 10:26   Re: sqlx my code wrong ?
Reply With Quote #5

Double post?? -/-
Code:
new DataNum[33];
SnoW is offline
Send a message via MSN to SnoW
DaniDin
Member
Join Date: Oct 2008
Old 12-26-2008 , 10:31   Re: sqlx my code wrong ?
Reply With Quote #6

sorry for the double i use ff so not all the picture show where they need ...
and i do what you say and it say
Error: Array must be indexed (variable "DataNum") on line 95
DaniDin is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 12-26-2008 , 10:36   Re: sqlx my code wrong ?
Reply With Quote #7

Ye but, look... You have to understand the difference between int and string. When you create new String[33] you have to use index there, like String[id] = "bllaaabla". Ofc when you read someone name get_user_name(id, String, 32), it's not needed because there is id on the native...
SnoW is offline
Send a message via MSN to SnoW
DaniDin
Member
Join Date: Oct 2008
Old 12-26-2008 , 10:46   Re: sqlx my code wrong ?
Reply With Quote #8

:\
i dont understated you can help me pls ?
DaniDin is offline
DaniDin
Member
Join Date: Oct 2008
Old 12-26-2008 , 11:31   Re: sqlx my code wrong ?
Reply With Quote #9

omg success
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
    
new str[33]
    while(
SQL_MoreResults(Query))
    {
        
DataNum SQL_ReadResult(Query,0,str,33)
       
        
server_cmd("amx_say some data: %s ",str)
    
        
SQL_NextRow(Query)
    }
   
    return 
PLUGIN_CONTINUE

thanks
DaniDin is offline
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 12-26-2008 , 13:50   Re: sqlx my code wrong ?
Reply With Quote #10

PHP Code:
DataNum SQL_ReadResult(Query,0,str,33
Completely unnecessary because DataNum is never used. Just use:

PHP Code:
SQL_ReadResult(Query,0,str,33
Spunky is offline
Send a message via AIM to Spunky
Reply


Thread Tools
Display Modes

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 09:16.


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