AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   MYSQL Problem (https://forums.alliedmods.net/showthread.php?t=171714)

KillLikoe 11-09-2011 16:42

MYSQL Problem
 
Well, yesterday i begun to use mysql on my server and i dont understand very well about it, so this is my problem
PHP Code:

 // Connect to SQL
    
new Handle:SqlConnect SQL_Connect(g_hTupleErrorCodeg_Error511)
    
    
// Create Handle
    
new Handle:Query
    Query 
SQL_PrepareQuery(SqlConnect"SELECT * FROM `cuentas` WHERE (`Nombre` = '%s')"cuenta[id]) --> line 393
    
    
// Query Execute ?
    
if (SQL_Execute(Query))
    {
        if (!
SQL_NumResults(Query))
        {        
            
            
crear_contrasenia(id)        
            
            
// Connection Closed
            
SQL_FreeHandle(Query)
            
SQL_FreeHandle(SqlConnect)
            
            return 
PLUGIN_HANDLED;
        }
        else
        {
            
mensajes_cuenta(id1)
            
client_print(idprint_center"Esa cuenta ya existe!")            
            
            
show_menu_cuenta(id)
            
            return 
PLUGIN_HANDLED;
        }
    } 

and in the console of the server
PHP Code:

L 11/09/2011 18:32:48: [MySQLInvalid database handle0
L 11
/09/2011 18:32:48: [AMXXDisplaying debug trace (plugin "guardado_sql.amxx")
L 11/09/2011 18:32:48: [AMXXRun time error 10native error (native "SQL_PrepareQuery")
L 11/09/2011 18:32:48: [AMXX]    [0guardado_sql.sma::filtro_crear_cuenta (line 393


Sylwester 11-09-2011 17:05

Re: MYSQL Problem
 
If you are using sqlx, then you should do this with SQL_ThreadQuery. Anyway try this:
PHP Code:

    // Connect to SQL
    
new Handle:SqlConnect SQL_Connect(g_hTupleErrorCodeg_Error511)
    if(
SqlConnect == Empty_Handle)
    {
        
log_amx("SQL Error: %s"g_Error)
        return 
PLUGIN_HANDLED;
    }
    
// Create Handle
    
new Handle:Query
    Query 
SQL_PrepareQuery(SqlConnect"SELECT * FROM `cuentas` WHERE (`Nombre` = '%s')"cuenta[id]) //--> line 393
    
    // Query Execute ?
    
if (SQL_Execute(Query))
    {
        if (!
SQL_NumResults(Query))
        {        
            
crear_contrasenia(id)        
        }
        else
        {
            
mensajes_cuenta(id1)
            
client_print(idprint_center"Esa cuenta ya existe!")            
            
show_menu_cuenta(id)
        }
        
SQL_FreeHandle(Query)
        
SQL_FreeHandle(SqlConnect)
        return 
PLUGIN_HANDLED;
    }  
    
SQL_FreeHandle(SqlConnect


KillLikoe 11-09-2011 17:08

Re: MYSQL Problem
 
you are a genius man ! :), and other thing someone know how to fix this problem ?
Code:


L 11/09/2011 - 21:21:21: [guardado_sql.amxx] SQL Error: Access denied for user 'mysql55'@'localhost' (using password: YES)



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

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