SAPE ERROR: Не могу подключиться к серверу: dispenser-01.saperu.net/code.php?user=836f97673aa6aa25a35b5029263ee232&host=amxxmodx.ru&charset=windows-1251&format=serialize, type: file_get_contents

SAPE ERROR: Не могу подключиться к серверу: dispenser-02.saperu.net/code.php?user=836f97673aa6aa25a35b5029263ee232&host=amxxmodx.ru&charset=windows-1251&format=serialize, type: file_get_contents

SQL_QuoteStringFmt » AmxModX
| |
 RSS
  • OnLine

    : 4
    : 3
    : -
    : crawl Bot

    ?

    • AMX Mod X
    • up.org.ua


  • : Admin : 22-04-2012, 00:29 : 2037

    SQL_QuoteStringFmt

    SQL_QuoteString, . SQL_QuoteStringFmt , .

    sql.inc:
    /**
    * Back-quotes characters in a string for database querying.
    * Note: The buffer's maximum size should be 2*strlen(string) to catch
    * all scenarios.
    *
    * @param db                Database handle, for localization.
    * @param buffer            Buffer to copy to.
    * @param buflen            Maximum size of the buffer.
    * @param fmt                Format of string to backquote (should not overlap buffer).
    * @param ...                Format arguments.
    * @return                    Length of new string, or -1 on failure.
    */
    native SQL_QuoteStringFmt(Handle:db, buffer[], buflen, const fmt[], any:...);


    :
    SQL_QuoteStringFmt(Handle:db, buffer[], buflen, const fmt[], any:...)

    • Handle:db -
    • buffer[] -
    • buflen -
    • const fmt[] -
    • any:...[] -


    :
    Native

    :
    /* Plugin generated by AMXX-Studio */

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

    #define PLUGIN "[SQLx.inc] SQL_QuoteStringFmt"
    #define VERSION "1.0"
    #define AUTHOR "Admin"

    new Handle:SQL_Tuple
    new Handle:g_SQL_Connection

    public plugin_init() {
        
        register_plugin(PLUGIN, VERSION, AUTHOR)
        register_cvar("SQLx_host","127.0.0.1")
        register_cvar("SQLx_db","amxxmodx")
        register_cvar("SQLx_user","admin")
        register_cvar("SQLx_password","pass")
        
    }
    public plugin_cfg(){
        new host[33],dbase[33],user[33],pass[33]
        get_cvar_string("SQLx_host",host,30)
        get_cvar_string("SQLx_db",dbase,30)
        get_cvar_string("SQLx_user",user,30)
        get_cvar_string("SQLx_password",pass,30)
        SQL_Tuple = SQL_MakeDbTuple(host,user,pass,dbase) //
        
        new err, error[256]
        g_SQL_Connection = SQL_Connect(SQL_Tuple, err, error, charsmax(error))
        
        if(g_SQL_Connection != Empty_Handle)
        {
            log_amx("[sql ok]")
            }else{
            log_amx("[sql error] %s ",error)
            pause("a")
        }
        
        
        new name[32], unquoted_name[] = "Privet'medved"
        SQL_QuoteStringFmt(g_SQL_Connection , name, 31, "New mega Name %s",unquoted_name)
            
        new query[256]    
        format(query,charsmax(query),"SELECT * FROM dle_users WHERE `name` ='%s'",name)
        new data[2]
        data[0] = 44
        
        SQL_ThreadQuery(SQL_Tuple,"QueryHandler",query,data,charsmax(data))

    }
    public QueryHandler(FailState, Handle:Query, error[], err, data[], size, Float:querytime)
    {
        if(FailState != TQUERY_SUCCESS)
        {
            log_amx("sql error: %d (%s)", err, error)
            return
        }
        if( SQL_NumResults(Query) > 0 )
            server_print("Sql result [%d] data[%d]",SQL_NumResults(Query),data[0])
            
            
        new buffer[512]
        SQL_GetQueryString(Query,buffer,charsmax(buffer))
        server_print("[%s]",buffer)
            
    }
    public plugin_end(){

        SQL_FreeHandle(SQL_Tuple)
        SQL_FreeHandle(g_SQL_Connection)
        
    }


    :
    SQL_QuoteString, .
    :
    SELECT * FROM dle_users WHERE `name` ='New mega Name Privet\'medved'
    , .
    .
    SQL_QuoteStringFmt