SQLite help!
#10

pawn Код:
#define FILTERSCRIPT

#include < a_samp >

new
    DB: Database
;

public OnFilterScriptInit( )
{
    Database = db_open( "DatabaseBLRP.db" );
   
    new
        DBResult: Result
    ;
    Result = db_query( Database, "SELECT * FROM users WHERE name = 'Danijel_Glupan' AND password = 'dado123'" );
    if( db_num_rows( Result ) )
    {
        new
            Field[ 2 ],
            admin = 0
        ;
        db_get_field_assoc( Result, "admin", Field, 2 );
        admin = strval( Field );
        printf( "Danijel_Glupan's admin level is %d", admin );
    }
    db_free_result( Result );
    return 1;
}

public OnFilterScriptExit( )
{
    db_close( Database );
    return 1;
}
pawn Код:
// Output:
[01:13:14] Danijel_Glupan's admin level is 1
If the field is "admin" then use it with that case, not "ADMIN".


EDIT: I think I didn't see that in your database and you must add that. It's about COLLATE NOCASE. When creating the table, set the name to:
pawn Код:
"CREATE TABLE IF NOT EXISTS users (name VARCHAR(24) COLLATE NOCASE, ... blabla.."
Because you can register the same name with different case (upper, lower).
Reply


Messages In This Thread
SQLite help! - by Danijel. - 06.07.2013, 15:28
Re: SQLite help! - by Misiur - 06.07.2013, 16:42
Re: SQLite help! - by Danijel. - 06.07.2013, 16:58
Re: SQLite help! - by Konstantinos - 06.07.2013, 17:11
Re: SQLite help! - by Danijel. - 06.07.2013, 18:01
Re: SQLite help! - by Konstantinos - 06.07.2013, 18:09
Re: SQLite help! - by Danijel. - 06.07.2013, 18:19
Re: SQLite help! - by Konstantinos - 06.07.2013, 19:28
Re: SQLite help! - by Danijel. - 06.07.2013, 20:30
Re: SQLite help! - by Konstantinos - 06.07.2013, 22:08

Forum Jump:


Users browsing this thread: 1 Guest(s)