AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help With Mysql Consult (https://forums.alliedmods.net/showthread.php?t=126730)

dark22 05-12-2010 23:16

Help With Mysql Consult
 
Hi,

Have searched around the forum, but does not have much knowledge of the module sqlx, so I ask for help to try to run the script below. What does he want to search the MySQL database, the server name if the name is not equal to table in the database, return error. The compilation does not return errors, but the plugin is unable to perform the search in the database.

Code:

#include < amxmodx >
#include < amxmisc >
#include < sqlx >

new Handle:g_hTuple;
new g_iError, g_szError[ 128 ];

public plugin_init( ) {
        g_hTuple = SQL_MakeStdTuple( );
       
        new Handle:hConnection = SQL_Connect( g_hTuple, g_iError, g_szError, 127 );
        if( hConnection == Empty_Handle ) {
                set_fail_state( g_szError );
        }
       
        VerifyTable( hConnection );
       
        SQL_FreeHandle( hConnection );
}

VerifyTable( Handle:hConnection ) {
        new Handle:hQuery = SQL_PrepareQuery( hConnection,
        "SELECT mydata FROM mytable WHERE id = 1"
        );
       
        if( !SQL_Execute( hQuery ) ) {
                SQL_QueryError( hQuery, g_szError, 127 );
                log_amx( "Failed to create table: %s", g_szError );
        }
       
        new hostname[64]
        get_cvar_string("hostname",hostname,63)

        //*if(contain(hostname, "My Hostname"))
        if(contain(hostname, "%s"),hQuery)
        set_fail_state("My Hostname incorrect")
}

This code was caught in the topic: (Credits for Exolent[jNr])

https://forums.alliedmods.net/showth...=103229&page=2

I appreciate any idea.


All times are GMT -4. The time now is 03:35.

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