Raised This Month: $ Target: $400
 0% 

[More Help] SQLx :D


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
quark
Veteran Member
Join Date: Oct 2011
Location: Your mind.
Old 09-30-2012 , 12:15   [More Help] SQLx :D
Reply With Quote #1

PHP Code:
public Load_Status(id)
{
    new 
szSteamId[32], szTemp[512]
    
get_user_authid(idszSteamIdcharsmax(szSteamId))
    
    new 
Data[1]
    
Data[0] = id
    
    format
(szTemp,charsmax(szTemp),"SELECT * FROM `%s` WHERE steamID = ^"%s^";",Table,szSteamId)
    
SQL_ThreadQuery(g_SqlTuple,"Load_Status2",szTemp,Data,1)
}

public 
Load_Status2(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
    if(
FailState == TQUERY_CONNECT_FAILED)
    {
        
log_amx("Load - Could not connect to SQL database.  [%d] %s"ErrcodeError)
    }
    else if(
FailState == TQUERY_QUERY_FAILED)
    {
        
log_amx("Load Query failed. [%d] %s"ErrcodeError)
    }
    
    new 
id
    id 
Data[0]
    
    if(
SQL_NumResults(Query) == 0
    {
        
//create table bla bla bla , i will make it soon.
    

    else 
    {
        
SQL_ReadResult(Query0nick[id])
        
SQL_ReadResult(Query1Skill[id])
    }
    
    return 
PLUGIN_HANDLED

So Nick is on Column 1 and Skill in Column 2 on SQL Table.
BUt this don't work, why?
__________________

Check out My Plugins:
qServerInfo ; ASKTAG
quark is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 09-30-2012 , 12:42   Re: [More Help] SQLx :D
Reply With Quote #2

Show how you make the connection.
Do you get any error?

Use formatex instead of format.
__________________

Last edited by Neeeeeeeeeel.-; 09-30-2012 at 12:43.
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
quark
Veteran Member
Join Date: Oct 2011
Location: Your mind.
Old 09-30-2012 , 14:41   Re: [More Help] SQLx :D
Reply With Quote #3

No errors.

Here is my connection:
PHP Code:
public MySql_Init()
{
    
g_SqlTuple SQL_MakeDbTuple(Host,User,Pass,Db)
    
    new 
ErrorCode,Handle:SqlConnection SQL_Connect(g_SqlTuple,ErrorCode,g_Error,charsmax(g_Error))
    
    if(
SqlConnection == Empty_Handleset_fail_state(g_Error)
    
    
SQL_FreeHandle(SqlConnection)   

__________________

Check out My Plugins:
qServerInfo ; ASKTAG
quark is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 09-30-2012 , 15:17   Re: [More Help] SQLx :D
Reply With Quote #4

http://forums.alliedmods.net/showthread.php?t=197059

PHP Code:
SELECT FROM table WHERE steam 'string'
// SELECT * FROM table WHERE steam = "string" // maybe wrong? 
PHP Code:
new String33 ][ 32 ];
new 
Numeric33 ];
new 
PlayerId;

SQL_ReadResulthQuery0StringPlayerId ], charsmaxStringPlayerId ] ) ); // For string variables like name/steam/ip address
NumericPlayerId ] = SQL_ReadResulthQuery); // For numeric values like frags/score/deaths 
__________________

Last edited by claudiuhks; 09-30-2012 at 15:19.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
quark
Veteran Member
Join Date: Oct 2011
Location: Your mind.
Old 09-30-2012 , 15:23   Re: [More Help] SQLx :D
Reply With Quote #5

hmmmmmmmmmm I will try, thanks.
__________________

Check out My Plugins:
qServerInfo ; ASKTAG

Last edited by quark; 09-30-2012 at 15:23.
quark is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 09-30-2012 , 17:54   Re: [More Help] SQLx :D
Reply With Quote #6

Now I see the error... you don't pass the fourth argument.
PHP Code:
SQL_ReadResultQuery0nickid ], charsmaxnick[ ] ) );
SQL_ReadResultQuery1Skillid ], charsmaxSkill[ ] ) ); 
__________________

Last edited by Neeeeeeeeeel.-; 09-30-2012 at 17:55.
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
quark
Veteran Member
Join Date: Oct 2011
Location: Your mind.
Old 10-01-2012 , 12:53   Re: [More Help] SQLx :D
Reply With Quote #7

Quote:
Originally Posted by Neeeeeeeeeel.- View Post
Now I see the error... you don't pass the fourth argument.
PHP Code:
SQL_ReadResultQuery0nickid ], charsmaxnick[ ] ) );
SQL_ReadResultQuery1Skillid ], charsmaxSkill[ ] ) ); 

Don't work.

Quote:
Originally Posted by claudiuhks View Post
http://forums.alliedmods.net/showthread.php?t=197059

PHP Code:
SELECT FROM table WHERE steam 'string'
// SELECT * FROM table WHERE steam = "string" // maybe wrong? 
PHP Code:
new String33 ][ 32 ];
new 
Numeric33 ];
new 
PlayerId;

SQL_ReadResulthQuery0StringPlayerId ], charsmaxString[  PlayerId ] ) ); // For string variables like name/steam/ip address
NumericPlayerId ] = SQL_ReadResulthQuery); // For numeric values like frags/score/deaths 
So i am using Hattrick, how can I get user name from database:

PHP Code:
public ReadDataPlayer ) {
  if( 
is_user_connectedPlayer ) ) {
    new 
File fopen"addons/QueryResult.ini""r" );

    if( 
File ) {
      new 
Frags10 ], Deaths10 ], Buffer1024 ];

      
fgetsFileBuffer1023 );

      
trimBuffer );

      if( !
strlenBuffer ) ) {
        
server_cmd"Query %s \"INSERT INTO players VALUES ( '%s', 0, 0 )\""gConnectionDatagNamePlayer ] );

        
gFragsPlayer ] = 0;
        
gDeathsPlayer ] = 0;

        return;
      }

      
//here but how? :|

      
parseBufferFrags9Deaths);

      
gFragsPlayer ] = str_to_numFrags );
      
gDeathsPlayer ] = str_to_numDeaths );

      
fcloseFile );
    }
  }

__________________

Check out My Plugins:
qServerInfo ; ASKTAG

Last edited by quark; 10-04-2012 at 07:18.
quark is offline
Old 10-01-2012, 13:27
quark
This message has been deleted by quark. Reason: Double.
Reply



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 23:08.


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