[Ajuda] Problema com MySql
#1

Estou tendo problema em dar insert em tabelas a primeira tabela Conta funciona corretamente ja as outras nao. Acredito q o problema e relacionado ao mysql_tquery ou algo do tipo
http://imgur.com/a/soHU6
Код:
public OnGameModeInit()
{
    SetGameModeText("BRUS RolePlay");
	IDConexao = mysql_connect(HOST, USUARIO, DATABASE, SENHA); 

    mysql_query(IDConexao, "CREATE TABLE IF NOT EXISTS `Contas`(`ID` int AUTO_INCREMENT PRIMARY KEY, `Nome` varchar(24) NOT NULL,`Senha` varchar(20) NOT NULL,`Level` int(20) NOT NULL,`Admin` int(20) NULL,`Skin` int(20),`Matou` int(10) NOT NULL,`Morreu` int(10) NOT NULL,`Dinheiro` int(20),`Banco` int(20),`Materiais` int(20),`Drogas` int(20),`Arma1` int(20),`Arma2` int(20),`Arma3` int(20),`Vida` int(20),`Colete` int(20),`W` int(20),`I` int(20),`X` float,`Y` float,`Z` float)", false);
    mysql_query(IDConexao, "CREATE TABLE IF NOT EXISTS `Orgs`  (`ID` int AUTO_INCREMENT PRIMARY KEY, `Nome` varchar(24) NOT NULL,`Existe` int(20),`Lider` varchar(24) NULL,`SubLider` varchar(24) NULL,`Cofre` int(20),`Cidade` int(20))",false);
    mysql_query(IDConexao, "CREATE TABLE IF NOT EXISTS `Playerdocs`  (`ID` int AUTO_INCREMENT PRIMARY KEY, `Nome` varchar(24) NOT NULL,`Vip` int(20),`Passaporte` int(20),`Visto` int(20),`Org` int(20),`Cargo` int(20),`Prof` int(20))",false);
   	mysql_query(IDConexao, "CREATE TABLE IF NOT EXISTS `Playerlics`  (`ID` int AUTO_INCREMENT PRIMARY KEY, `Nome` varchar(24) NOT NULL,`LicArma` int(20),`LicCarro` int(20) NULL,`LicMoto` int(20) NULL,`LicCaminhao` int(20),`LicBarco` int(20),`LicAviao` int(20),`LicHeli` int(20),`LicPesca` int(20))",false);
    mysql_query(IDConexao, "CREATE TABLE IF NOT EXISTS `Playerprop`  (`ID` int AUTO_INCREMENT PRIMARY KEY, `Nome` varchar(24) NOT NULL,`Casa1` int(20),`Casa2` int(20),`Carro1` int(20),`Carro2` int(20) NULL,`Carro3` int(20) NULL,`Carro4` int(20),`Carro5` int(20),`Carro6` int(20))",false);
    if(mysql_errno(IDConexao) != 0)
	{
        print("Falha na conexгo ao banco de dados Mysql");
  	}else{
   		print("Conexгo ao banco de dado Mysql efetuada com sucesso");
    }return 1;
}
Код:
stock RegistrarConta(playerid)
{  
    PlayerInfo[playerid][pDinheiro] = 5000; // ou seja comeзara com 5000 reais
    PlayerInfo[playerid][pAdmin] = 0; // sem nivel de admin
    PlayerInfo[playerid][pLevel] = 1; // 1 level
    PlayerInfo[playerid][pSkin] = 299; // skin 299
    PlayerInfo[playerid][pMorreu] = 0; // ....
    PlayerInfo[playerid][pMatou] = 0;
    PlayerInfo[playerid][pBanco] = 0;
    PlayerInfo[playerid][pMateriais] = 0;
    PlayerInfo[playerid][pDrogas] = 0;
    PlayerInfo[playerid][pArma1] = 0;
    PlayerInfo[playerid][pArma2] = 0;
    PlayerInfo[playerid][pArma3] = 0;
    PlayerInfo[playerid][pVida] = 0;
    PlayerInfo[playerid][pColete] = 0;
	printf("1");
    new Query[300];
    mysql_format(IDConexao, Query, sizeof(Query), "INSERT INTO `contas` (`Nome`,`Senha`,`Level`,`Admin`,`Skin`,`Matou`,`Morreu`,`Dinheiro`,`Banco`,`Materiais`,`Drogas`,`Arma1`,`Arma2`,`Arma3`,`Vida`,`Colete`,`W`,`I`,`X`,`Y`,`Z`) VALUES ('%e','%s','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%f','%f','%f')",
    Nome(playerid),
    PlayerInfo[playerid][pSenha],
    PlayerInfo[playerid][pLevel],
    PlayerInfo[playerid][pAdmin],
    PlayerInfo[playerid][pSkin],
    PlayerInfo[playerid][pMatou],
    PlayerInfo[playerid][pMorreu],
    PlayerInfo[playerid][pDinheiro],
	PlayerInfo[playerid][pBanco],
	PlayerInfo[playerid][pMateriais],
	PlayerInfo[playerid][pDrogas],
	PlayerInfo[playerid][pArma1],
	PlayerInfo[playerid][pArma2],
	PlayerInfo[playerid][pArma3],
	PlayerInfo[playerid][pVida],
	PlayerInfo[playerid][pColete],
	PlayerInfo[playerid][pW],
	PlayerInfo[playerid][pI],
	PlayerInfo[playerid][pX],
	PlayerInfo[playerid][pY],
	PlayerInfo[playerid][pZ]);


    mysql_tquery(IDConexao, Query,"DadosSalvos","d", playerid);// consulta, e enviamos o resultado para a callback DadosSalvos para um DEBUG

    CarregarDados(playerid);
    return 1;
}

stock RegistrarPlayerLics(playerid)
{

    new Query[300];
	mysql_format(IDConexao, Query, sizeof(Query),"INSERT INTO `playerlics` (`Nome`,`LicArma`,`LicCarro`,`LicMoto`,`LicCaminhao`,`LicBarco`,`LicAviao`,`LicHeli`,`LicPesca`) VALUES ('%e',%d','%d','%d','%d','%d','%d','%d','%d')",
    Nome(playerid),
	PlayerInfo[playerid][pLicArma],
	PlayerInfo[playerid][pLicCarro],
	PlayerInfo[playerid][pLicMoto],
	PlayerInfo[playerid][pLicCaminhao],
	PlayerInfo[playerid][pLicBarco],
	PlayerInfo[playerid][pLicAviao],
	PlayerInfo[playerid][pLicHeli],
	PlayerInfo[playerid][pLicPesca]);
    PlayerInfo[playerid][pLicArma] = 0;
    PlayerInfo[playerid][pLicCarro] = 0;
    PlayerInfo[playerid][pLicMoto] = 0;
    PlayerInfo[playerid][pLicCaminhao] = 0;
    PlayerInfo[playerid][pLicBarco] = 0;
    PlayerInfo[playerid][pLicAviao] = 0;
    PlayerInfo[playerid][pLicHeli] = 0;
    PlayerInfo[playerid][pLicPesca] = 0;
    mysql_pquery(IDConexao,Query);
    //mysql_tquery(IDConexao, Query,"PlayerLicsSalvos","d", playerid);// consulta, e enviamos o resultado para a callback DadosSalvos para um DEBUG
    return 1;
}
stock RegistrarPlayerDocs(playerid)
{
	new Query[300];
    PlayerInfo[playerid][pVip] = 0;
    PlayerInfo[playerid][pPassaporte] = 0;
    PlayerInfo[playerid][pVisto] = 0;
    PlayerInfo[playerid][pOrg] = 0;
    PlayerInfo[playerid][pCargo] = 0;
    PlayerInfo[playerid][pProf] = 0;

	mysql_format(IDConexao, Query, sizeof(Query), "INSERT INTO `Playerdocs` (`Nome`,`Vip`,`Passaporte`,`Visto`,`Org`,`Cargo`,`Prof`) VALUES ('%e',%d','%d','%d','%d','%d','%d')",
	Nome(playerid),
	PlayerInfo[playerid][pVip],
	PlayerInfo[playerid][pPassaporte],
	PlayerInfo[playerid][pVisto],
	PlayerInfo[playerid][pOrg],
	PlayerInfo[playerid][pCargo],
	PlayerInfo[playerid][pProf]);

    mysql_tquery(IDConexao, Query,"PlayerDocsSalvos","d", playerid);
	return 1;
}
stock RegistrarPlayerProps(playerid)
{
	new Query[300];
    PlayerInfo[playerid][pCasa1] = 0;
    PlayerInfo[playerid][pCasa2] = 0;
    PlayerInfo[playerid][pCarro1] = 0;
    PlayerInfo[playerid][pCarro2] = 0;
    PlayerInfo[playerid][pCarro3] = 0;
    PlayerInfo[playerid][pCarro4] = 0;
    PlayerInfo[playerid][pCarro5] = 0;
    PlayerInfo[playerid][pCarro6] = 0;
    mysql_format(IDConexao, Query, sizeof(Query),"INSERT INTO `playerprops` (`Nome`,`Casa1`,`Casa2`,`Carro1`,`Carro2`,`Carro3`,`Carro4`,`Carro5`,`Carro6`) VALUES ('%e',%d','%d','%d','%d','%d','%d','%d','%d')",
	Nome(playerid),
	PlayerInfo[playerid][pCasa1],
	PlayerInfo[playerid][pCasa2],
	PlayerInfo[playerid][pCarro1],
	PlayerInfo[playerid][pCarro2],
	PlayerInfo[playerid][pCarro3],
	PlayerInfo[playerid][pCarro4],
	PlayerInfo[playerid][pCarro5],
	PlayerInfo[playerid][pCarro6]);

    mysql_tquery(IDConexao, Query,"PlayerPropsSalvos","d", playerid);
	return 1;
}
Reply
#2

mostre o log do mysql do seu servidor!
Reply
#3

Recomendo vocк usar DEFAULT no lugar de NOT NULL/NULL (no CREATE TABLE), com ele vocк nгo precisa adicionar a coluna no INSERT.

Exemplo:
Код:
`Admin` int(20) DEFAULT 0
Ao executar INSERT sem adicionar a coluna Admin, ela serб definida automaticamente com valor 0.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)