AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Error with MySql_Init (https://forums.alliedmods.net/showthread.php?t=147811)

reinert 01-14-2011 11:00

Error with MySql_Init
 
Quote:

L 01/14/2011 - 17:58:24: [AMXX] Plugin says: Incorrect table definition; there can be only one auto column and it must be defined as a key
L 01/14/2011 - 17:58:24: [AMXX] Displaying debug trace (plugin "xx.amxx")
L 01/14/2011 - 17:58:24: [AMXX] Run time error 1: forced exit
L 01/14/2011 - 17:58:24: [AMXX] [0] xx.sma::MySql_Init (line 807)
MySql_Init:


PHP Code:

public MySql_Init()
{
    if(
get_pcvar_num(cvar_plugin) == 0)
        return 
PLUGIN_CONTINUE;
        
    
g_SqlTuple SQL_MakeDbTuple(Host,User,Pass,Db);
   
    new 
ErrorCode,Handle:SqlConnection SQL_Connect(g_SqlTuple,ErrorCode,g_Error,charsmax(g_Error));
    
    if(
SqlConnection == Empty_Handle)
    
set_fail_state(g_Error);
       
    new 
Handle:Queries;
    
Queries SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS aa (id INT(11) NOT NULL AUTO_INCREMENT, steam varchar(32), lak int(12) NOT NULL default '0', auto INT(1) NOT NULL default '0', auto_lak INT(2) NOT NULL, access INT(1) NOT NULL default '0', welcome INT(1) NOT NULL default '0', welcome_msg varchar(256) NOT NULL)");

    if(!
SQL_Execute(Queries))
    {
        
SQL_QueryError(Queries,g_Error,charsmax(g_Error));
        
set_fail_state(g_Error);
    }
    
    
SQL_FreeHandle(Queries);
    
SQL_FreeHandle(SqlConnection);
    
    return 
PLUGIN_HANDLED;



Sylwester 01-14-2011 16:25

Re: Error with MySql_Init
 
try this:
PHP Code:

"CREATE TABLE IF NOT EXISTS aa (id INT(11) NOT NULL AUTO_INCREMENT UNIQUE KEY, steam varchar(32), lak int(12) NOT NULL default '0', auto  INT(1) NOT NULL default '0', auto_lak INT(2) NOT NULL, access INT(1) NOT  NULL default '0', welcome INT(1) NOT NULL default '0', welcome_msg  varchar(256) NOT NULL, PRIMARY KEY ( steam ));" 



All times are GMT -4. The time now is 02:14.

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