Raised This Month: $ Target: $400
 0% 

[MYSQL] Query Problem


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
HENNESSY
Member
Join Date: Sep 2013
Location: Russian Federation, Bela
Old 07-16-2014 , 05:49   [MYSQL] Query Problem
Reply With Quote #1

I'm try to get some data from the database

This is the code:

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

#define hostname	"hidden"
#define sql_user	"hidden"
#define sql_pass	"hidden"
#define sql_db	"hidden"

new Handle:g_hTuple;
new g_szError[ 512 ];

public plugin_init( )
{
g_hTuple =	SQL_MakeDbTuple( hostname, sql_user, sql_pass, sql_db );

register_clcmd( "say vipstatus", "cmd_Vipstatus" );
}

public cmd_Vipstatus( iIndex )
{
new szSteamID[ 35 ];
get_user_authid( iIndex, szSteamID, charsmax( szSteamID ) );

new iError, Handle:hSQLConnection = SQL_Connect( g_hTuple, iError, g_szError, 511 );

if( hSQLConnection == Empty_Handle )
{
set_fail_state( g_szError );
}

new Handle:hQuery = SQL_PrepareQuery( hSQLConnection, "SELECT `package_id`, `server_id` FROM `vips` WHERE `steamid` = '%s';", szSteamID );

static szServerID[ 3 ], iPackageID;

if( !SQL_Execute( hQuery ) )
{
SQL_QueryError( hQuery, g_szError, 511 );
log_amx( "Query Error: %s", g_szError );
}

else if( SQL_NumResults( hQuery ) )
{
iPackageID = SQL_ReadResult( hQuery, 0 );
SQL_ReadResult( hQuery, 1, szServerID, charsmax( szServerID ) );

client_print( iIndex, print_chat, "You are a VIP with the package ID: %i on server %s", iPackageID, szServerID );
}

SQL_FreeHandle( hQuery );
SQL_FreeHandle( hSQLConnection );
}
public plugin_end( )
{
SQL_FreeHandle( g_hTuple );
}
The connection succeed but when i write 'vipstatus' in chat it just lag the server for a second and doesn't show anything.

I run the query on the database and it returning my requested values;

What is the problem with my code?

Thanks for the Help!

Last edited by YamiKaitou; 07-18-2014 at 06:24. Reason: Problem fixed!
HENNESSY 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 13:18.


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