Mysql Error
#1

Hello friends, I am learning MYSQL, I have an idea of pawno, but I am interested in learning about mysql and I have a gm where I can register normally, but then when I want to register another account, when I pass the part of placing a password it the dialog box comes out and the screen remains without loading anything else, when I look at the logs this appears.

MYSQL - ERRORID: 1062
Error: Duplicate entry '0' for key 'PRIMARY'
Query: INSERT INTO `Usuarios` (`Nombre`, `Clave`, `email`) VALUES ('Trevor_Winebackss', 126419382, 'nomail')
Callback: OnQueryFinish

Codes:

PHP Code:
stock CrearCuenta(playerid, const name[], const encryptedemail[])
{
    new
        
querystr [211];
    
InfoJugador[playerid][jClave] = encrypted;
    
opmysql_format(querystrsizeof (querystr), "INSERT INTO `Usuarios` (`Nombre`, `Clave`, `email`) VALUES ('%e', %d, '%e')"nameencryptedemail);
    
opmysql_tqueryquerystr"OnQueryFinish""ii"playeridquery_type_createaccount);
    
//Dialog (playerid, dRegistro, DIALOG_STYLE_MSGBOX, ""#CINFO"ЎCuenta registrada!", ""#CBLANCO"\n\nSu cuenta fue creada exitosamente, Ўahora puede comenzar a jugar!\n\n", "Jugar", "");
    
SetPVarInt (playerid"pRegistro"5);
    
printf("Consulta ejecutada | CUENTA: %s | QUERY : %s"querystr); 
    return 
1;

I do not know if something needs to be configured here:

PHP Code:
static
    const 
table_Usuarios[] = "CREATE TABLE IF NOT EXISTS `Usuarios` (`userID` INT(8) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`userID`) );";
static
    const 
table_Usuarios_data[][] =
    {
        
"`Nombre` VARCHAR(24) NOT NULL",
        
"`Clave` INT(11) NOT NULL",
        
"`email` VARCHAR(38) NOT NULL",
        
"`ip` VARCHAR(16) NOT NULL",
        
"`UltimaConexion` VARCHAR(25) NOT NULL",
        
"`Registrado` BOOLEAN NOT NULL",
        
"`Sexo` TINYINT(2) NOT NULL",
        
"`Edad` SMALLINT(5) NOT NULL",
        
"`Pelea` SMALLINT(5) NOT NULL",
        
"`Estilo` SMALLINT(5) NOT NULL",
        
"`DNI` INT(11) NOT NULL",
        
"`Vida` FLOAT(11) NOT NULL",
        
"`Chaleco` FLOAT(11) NOT NULL",
        
"`Ropa_0` SMALLINT(5) NOT NULL",
        
"`Ropa_1` SMALLINT(5) NOT NULL",
        
"`Ropa_2` SMALLINT(5) NOT NULL",
        
"`Ropa_3` SMALLINT(5) NOT NULL",
        
"`CurrentSkin` SMALLINT(4) NOT NULL",
        
"`Dinero` INT(11) NOT NULL",
        
"`Banco` INT(11) NOT NULL",
        
"`Experiencia` FLOAT(11) NOT NULL",
        
"`Hambre` FLOAT(11) NOT NULL",
        
"`Cansancio` FLOAT(11) NOT NULL",
        
"`Orina` FLOAT(11) NOT NULL",
        
"`PosX` FLOAT(11) NOT NULL",
        
"`PosY` FLOAT(11) NOT NULL",
        
"`PosZ` FLOAT(11) NOT NULL",
        
"`Interior` INT(7) NOT NULL",
        
"`VirtualWorld` INT(11) NOT NULL",
        
"`inv_0` MEDIUMINT(5) NOT NULL",
        
"`invd_0` INT(12) NOT NULL",
        
"`inv_1` MEDIUMINT(5) NOT NULL",
        
"`invd_1` INT(12) NOT NULL",
        
"`inv_2` MEDIUMINT(5) NOT NULL",
        
"`invd_2` INT(12) NOT NULL",
        
"`inv_3` MEDIUMINT(5) NOT NULL",
        
"`invd_3` INT(12) NOT NULL",
        
"`inv_4` MEDIUMINT(5) NOT NULL",
        
"`invd_4` INT(12) NOT NULL",
        
"`inv_5` MEDIUMINT(5) NOT NULL",
        
"`invd_5` INT(12) NOT NULL",
        
"`inv_6` MEDIUMINT(5) NOT NULL",
        
"`invd_6` INT(12) NOT NULL",
        
"`inv_7` MEDIUMINT(5) NOT NULL",
        
"`invd_7` INT(12) NOT NULL",
        
"`inv_8` MEDIUMINT(5) NOT NULL",
        
"`invd_8` INT(12) NOT NULL",
        
"`inv_9` MEDIUMINT(5) NOT NULL",
        
"`invd_9` INT(12) NOT NULL",
        
"`Admin` INT(11) NOT NULL",
        
"`Lider` TINYINT(3) NOT NULL",
        
"`Miembro` TINYINT(3) NOT NULL",
        
"`FacDuty` TINYINT(3) NOT NULL",
        
"`Rango` TINYINT(3) NOT NULL",
        
"`Encarcelado` TINYINT(3) NOT NULL",
        
"`TiempoCarcel` INT(11) NOT NULL",
        
"`Minutos` INT(11) NOT NULL",
        
"`Horas` INT(11) NOT NULL",
        
"`Nivel` INT(11) NOT NULL",
        
"`LiderFam` TINYINT(3) NOT NULL",
        
"`MiembroFam` TINYINT(3) NOT NULL",
        
"`RangoFam` TINYINT(3) NOT NULL",
        
"`Trabajo` TINYINT(3) NOT NULL",
        
"`NivelTrabajo` SMALLINT(5) NOT NULL",
        
"`Entregas` MEDIUMINT(6) NOT NULL",
        
"`Necesidades` TINYINT(3) NOT NULL",
        
"`IDCuentaB` INT(5) NOT NULL",
        
"`CurrentObj` MEDIUMINT(5) NOT NULL",
        
"`CurrentObjD` INT(11) NOT NULL",
        
"`ObjetoColgado` MEDIUMINT(5) NOT NULL",
        
"`ObjetoColgadoData` INT(11) NOT NULL",
        
"`ChalecoObj` MEDIUMINT(5) NOT NULL",
        
"`ChalecoData` INT(11) NOT NULL",
        
"`BuscadorVeh` BOOLEAN NOT NULL",
        
"`AdminJail` VARCHAR(24) NOT NULL",
        
"`LicenciaAuto` BOOLEAN NOT NULL",
        
"`LicenciaMoto` BOOLEAN NOT NULL",
        
"`LicenciaArmas` BOOLEAN NOT NULL",
        
"`Cosechas` MEDIUMINT(6) NOT NULL",
        
"`AttachModel_0` INT(11) NOT NULL",
        
"`AttachModel_1` INT(11) NOT NULL",
        
"`AttachModel_2` INT(11) NOT NULL",
        
"`AttachModel_3` INT(11) NOT NULL",
        
"`AttachModel_4` INT(11) NOT NULL",
        
"`AttachBone_0` SMALLINT(3) NOT NULL",
        
"`AttachBone_1` SMALLINT(3) NOT NULL",
        
"`AttachBone_2` SMALLINT(3) NOT NULL",
        
"`AttachBone_3` SMALLINT(3) NOT NULL",
        
"`AttachBone_4` SMALLINT(3) NOT NULL",
        
"`AttachOcultado_0` BOOLEAN NOT NULL",
        
"`AttachOcultado_1` BOOLEAN NOT NULL",
        
"`AttachOcultado_2` BOOLEAN NOT NULL",
        
"`AttachOcultado_3` BOOLEAN NOT NULL",
        
"`AttachOcultado_4` BOOLEAN NOT NULL",
        
"`Estrellas` MEDIUMINT(7) NOT NULL",
        
"`Bomba` BOOLEAN NOT NULL",
        
"`Repartidas` MEDIUMINT(6) NOT NULL",
        
"`Barridas` MEDIUMINT(6) NOT NULL",
        
"`Acento` TINYINT(3) NOT NULL",
        
"`Muerto` BOOLEAN NOT NULL",
        
"`BlockDudas` BOOLEAN NOT NULL",
        
"`BlockFam` BOOLEAN NOT NULL",
        
"`BlockFac` BOOLEAN NOT NULL",
        
"`Esposado` BOOLEAN NOT NULL",
        
"`TiempoDudas` INT(11) NOT NULL",
        
"`Ibu400` INT(7) NOT NULL",
        
"`Ibu600` INT(7) NOT NULL",
        
"`Falopeado` INT(6) NOT NULL",
        
"`Papeado` INT(6) NOT NULL",
        
"`Adv` TINYINT(3) NOT NULL",
        
"`AdmAdv` TINYINT(3) NOT NULL",
        
"`AttachPosx_0` FLOAT(11) NOT NULL",
        
"`AttachPosx_1` FLOAT(11) NOT NULL",
        
"`AttachPosx_2` FLOAT(11) NOT NULL",
        
"`AttachPosx_3` FLOAT(11) NOT NULL",
        
"`AttachPosx_4` FLOAT(11) NOT NULL",
        
"`AttachPosy_0` FLOAT(11) NOT NULL",
        
"`AttachPosy_1` FLOAT(11) NOT NULL",
        
"`AttachPosy_2` FLOAT(11) NOT NULL",
        
"`AttachPosy_3` FLOAT(11) NOT NULL",
        
"`AttachPosy_4` FLOAT(11) NOT NULL",
        
"`AttachPosz_0` FLOAT(11) NOT NULL",
        
"`AttachPosz_1` FLOAT(11) NOT NULL",
        
"`AttachPosz_2` FLOAT(11) NOT NULL",
        
"`AttachPosz_3` FLOAT(11) NOT NULL",
        
"`AttachPosz_4` FLOAT(11) NOT NULL",
        
"`AttachAngx_0` FLOAT(11) NOT NULL",
        
"`AttachAngx_1` FLOAT(11) NOT NULL",
        
"`AttachAngx_2` FLOAT(11) NOT NULL",
        
"`AttachAngx_3` FLOAT(11) NOT NULL",
        
"`AttachAngx_4` FLOAT(11) NOT NULL",
        
"`AttachAngy_0` FLOAT(11) NOT NULL",
        
"`AttachAngy_1` FLOAT(11) NOT NULL",
        
"`AttachAngy_2` FLOAT(11) NOT NULL",
        
"`AttachAngy_3` FLOAT(11) NOT NULL",
        
"`AttachAngy_4` FLOAT(11) NOT NULL",
        
"`AttachAngz_0` FLOAT(11) NOT NULL",
        
"`AttachAngz_1` FLOAT(11) NOT NULL",
        
"`AttachAngz_2` FLOAT(11) NOT NULL",
        
"`AttachAngz_3` FLOAT(11) NOT NULL",
        
"`AttachAngz_4` FLOAT(11) NOT NULL",
        
"`AttachEscx_0` FLOAT(11) NOT NULL",
        
"`AttachEscx_1` FLOAT(11) NOT NULL",
        
"`AttachEscx_2` FLOAT(11) NOT NULL",
        
"`AttachEscx_3` FLOAT(11) NOT NULL",
        
"`AttachEscx_4` FLOAT(11) NOT NULL",
        
"`AttachEscy_0` FLOAT(11) NOT NULL",
        
"`AttachEscy_1` FLOAT(11) NOT NULL",
        
"`AttachEscy_2` FLOAT(11) NOT NULL",
        
"`AttachEscy_3` FLOAT(11) NOT NULL",
        
"`AttachEscy_4` FLOAT(11) NOT NULL",
        
"`AttachEscz_0` FLOAT(11) NOT NULL",
        
"`AttachEscz_1` FLOAT(11) NOT NULL",
        
"`AttachEscz_2` FLOAT(11) NOT NULL",
        
"`AttachEscz_3` FLOAT(11) NOT NULL",
        
"`AttachEscz_4` FLOAT(11) NOT NULL"
     
}; 
I can not find what to do because I've just started learning from MYSQL, I'm waiting for an answer.

Thank you.
Reply
#2

First check the PRIMARY KEY which is `userID`. Ensure it is set as AUTO INCREMENT because when this error is given, it is most likely not.

Since you started learning MySQL, read this: https://en.wikipedia.org/wiki/Database_normalization
Do not try to insert all data into one big table, separate them where possible. A new table for attachments and for what inv_X and invdX columns are used.
Reply
#3

Code:
        "`AttachPosx_0` FLOAT(11) NOT NULL", 
        "`AttachPosx_1` FLOAT(11) NOT NULL", 
        "`AttachPosx_2` FLOAT(11) NOT NULL", 
        "`AttachPosx_3` FLOAT(11) NOT NULL", 
        "`AttachPosx_4` FLOAT(11) NOT NULL", 
        "`AttachPosy_0` FLOAT(11) NOT NULL", 
        "`AttachPosy_1` FLOAT(11) NOT NULL", 
        "`AttachPosy_2` FLOAT(11) NOT NULL", 
        "`AttachPosy_3` FLOAT(11) NOT NULL", 
        "`AttachPosy_4` FLOAT(11) NOT NULL", 
        "`AttachPosz_0` FLOAT(11) NOT NULL", 
        "`AttachPosz_1` FLOAT(11) NOT NULL", 
        "`AttachPosz_2` FLOAT(11) NOT NULL", 
        "`AttachPosz_3` FLOAT(11) NOT NULL", 
        "`AttachPosz_4` FLOAT(11) NOT NULL", 
        "`AttachAngx_0` FLOAT(11) NOT NULL", 
        "`AttachAngx_1` FLOAT(11) NOT NULL", 
        "`AttachAngx_2` FLOAT(11) NOT NULL", 
        "`AttachAngx_3` FLOAT(11) NOT NULL", 
        "`AttachAngx_4` FLOAT(11) NOT NULL", 
        "`AttachAngy_0` FLOAT(11) NOT NULL", 
        "`AttachAngy_1` FLOAT(11) NOT NULL", 
        "`AttachAngy_2` FLOAT(11) NOT NULL", 
        "`AttachAngy_3` FLOAT(11) NOT NULL", 
        "`AttachAngy_4` FLOAT(11) NOT NULL", 
        "`AttachAngz_0` FLOAT(11) NOT NULL", 
        "`AttachAngz_1` FLOAT(11) NOT NULL", 
        "`AttachAngz_2` FLOAT(11) NOT NULL", 
        "`AttachAngz_3` FLOAT(11) NOT NULL", 
        "`AttachAngz_4` FLOAT(11) NOT NULL", 
        "`AttachEscx_0` FLOAT(11) NOT NULL", 
        "`AttachEscx_1` FLOAT(11) NOT NULL", 
        "`AttachEscx_2` FLOAT(11) NOT NULL", 
        "`AttachEscx_3` FLOAT(11) NOT NULL", 
        "`AttachEscx_4` FLOAT(11) NOT NULL", 
        "`AttachEscy_0` FLOAT(11) NOT NULL", 
        "`AttachEscy_1` FLOAT(11) NOT NULL", 
        "`AttachEscy_2` FLOAT(11) NOT NULL", 
        "`AttachEscy_3` FLOAT(11) NOT NULL", 
        "`AttachEscy_4` FLOAT(11) NOT NULL", 
        "`AttachEscz_0` FLOAT(11) NOT NULL", 
        "`AttachEscz_1` FLOAT(11) NOT NULL", 
        "`AttachEscz_2` FLOAT(11) NOT NULL", 
        "`AttachEscz_3` FLOAT(11) NOT NULL", 
        "`AttachEscz_4` FLOAT(11) NOT NULL"
And someone blamed me for my "wrong" database queries....

@OP: No need to do all this derby smashing queries when creating an account. Just set default values and insert only the most important ones. Such as account ID, password and email.

Also set your userID to AUTO_INCREMENT and PRIMARY.
Reply
#4

I do not understand what needs to be edited in order for the registry to work again.
Reply
#5

Execute this query in phpMyAdmin, command line or anywhere else:
pawn Code:
SHOW CREATE TABLE Usuarios;
and post the output. It will show columns, data types and keys.
Reply
#6

Estructure of usuarios.

https://i.gyazo.com/606fb052bca1ddee...384e000ea1.png
Reply
#7

Extra would show AUTO_INCREMENT for column `userID` if it was set but it is not.

Empty the table and click on "Cambiar" ("Change") for `userID` and tick "A_I" field or execute:
pawn Code:
ALTER TABLE Usuarios MODIFY userID INT(8) UNSIGNED NOT NULL AUTO_INCREMENT;
Reply
#8

I tick A_I field: Error:

https://i.gyazo.com/f25b20636ba11330...9ead79f078.png
Reply
#9

Error Fixed. Thx
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)