Raised This Month: $ Target: $400
 0% 

[SQL] result help


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Mulan
Senior Member
Join Date: Jul 2005
Location: [GER]Worbis
Old 08-12-2010 , 13:58   [SQL] result help
Reply With Quote #1

I have a problem with my script.
This script put mapnames in my Mysql-Database. The Problem is, comes the map again, the script write the map in the Database again -.-

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

#define PLUGIN    "Web_mapnames" 
#define AUTHOR    "by me" 
#define VERSION    "1.0 beta" 

new Handle:DB_TUPLE 
new error[512
new 
error_code 
new Handle:DB_CONNECT 

public plugin_cfg()
{
    
server_cmd("make_map")


public 
plugin_init() 

    
register_plugin(PLUGINVERSIONAUTHOR
    
    
register_srvcmd"make_map""selectfrom_map_table" )
    
    
register_cvar"js_db_host""xxx" 
    
register_cvar"js_db_user""xxx" 
    
register_cvar"js_db_pass""xxx" 
    
register_cvar"js_db_name""xxx" 
    
    static 
host[32], user[32], pass[32], name[32
    
    
get_cvar_string"js_db_host"host31 
    
get_cvar_string"js_db_user"user31 
    
get_cvar_string"js_db_pass"pass31 
    
get_cvar_string"js_db_name"name31 
    
    
DB_TUPLE=SQL_MakeDbTuple(host,user,pass,name
    
DB_CONNECT=SQL_Connect(DB_TUPLEerror_codeerror516); 
    
    if(
DB_CONNECT == Empty_Handle
        
set_fail_state(error
    
    new 
query[1024
    
    
formatexquery1023"create table if not exists map_names (map varchar(32))"mapname
    
SQL_ThreadQueryDB_TUPLE"db_generic_handler"query 
}

public 
selectfrom_map_table()
{
    new 
query[34
    
    
formatexquery33"SELECT * FROM map_names"
    
SQL_ThreadQueryDB_TUPLE"map_handler"query 
}

public 
map_handler(failstateHandle:queryerror[], errnumdata[], sizeFloat:queuetime
{
        if(!
SQL_MoreResults(query))    
            {  
                new 
query[34
                
get_mapname(mapname32
                
formatexquery33"INSERT INTO `map_names` VALUES ('%s')"mapname )
                
SQL_ThreadQuery(DB_TUPLE,"db_save_handler",query)
            }
            else
            {
                
log_amx("[MAPHANDLER] %s schon vorhanden!"mapname
            } 
}

public 
db_generic_handler(failstateHandle:queryerror[], errnumdata[], sizeFloat:queuetime

    return 
query_failedfailstateerrorerrnum 


public 
db_save_handlerfailstateHandle:queryerror[], errnumdata[], sizeFloat:queuetime 

    return 
query_failedfailstateerrorerrnum 


public 
query_failedfailstateerror[], errnum 

    if( 
failstate == TQUERY_CONNECT_FAILED 
    { 
        
log_amx"Couldn't connect to database: %s"error 
        return 

    

    else if( 
failstate == TQUERY_QUERY_FAILED 
    { 
        
log_amx"Query failed: %s"error 
        return 

    

    
    if( 
errnum 
    { 
        
log_amx"Query Error: %s"error 
        return 

    

    
    return 



public 
plugin_end() 

    
SQL_FreeHandle(DB_TUPLE


Last edited by Mulan; 08-12-2010 at 14:18.
Mulan is offline
Send a message via ICQ to Mulan
 



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 21:52.


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