Not exist? Mysql? WTF - help me
#1

Error when i use /fcreate Teste


But this table exist:



Code

Код:
	CMD:fcreate(playerid,params[])	{
		//new string[40],
		new query[128], localfname[32];
		if(sscanf(params,"s", localfname)) return SendClientMessage(playerid, -1, "Use: /fcreate [name]");
		//if(scorelevel[playerid] < 500) return SendClientMessage(playerid, COLOR_RED, "Vocк precisa ter score/level 500 para criar uma faction");
		if(GetPlayerMoneyEx(playerid) < 500000) return SendClientMessage(playerid, COLOR_RED, "You do not have 500.000");
		if(fmembro[playerid] > 0) return SendClientMessage(playerid, COLOR_RED, "Vocк jб tem uma faction");

		format(query,sizeof query,"SELECT COUNT(*) AS `exists` FROM factions WHERE facname='%s'",localfname);
		mysql_function_query(ConnectMYSQL,query,true,"r@MySQL_CheckFaction","ds",playerid, localfname);
		// /\ importante deixar o cache como TRUE.
		return 1;
	}
Код:
public r@MySQL_CheckFaction(playerid, name[]) {
    new field[11], exists;
    cache_get_field_content(0, "exists", field, ConnectMYSQL);
    exists = strval(field);

    if(exists) {
        // jб existe
        return 1;
    }

    new cargocinco = 5;
    new cargozero = 0;

    new ept[30];
    ept = "Empty";

    new seunome[30];
    seunome = PlayerName(playerid);

    new query[1024];
	
	new partquery[500];
	format(partquery, sizeof(partquery), "INSERT INTO `factions` VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d',", name, seunome, ept, ept, ept, ept, ept, ept, ept, ept, ept, ept, ept, ept, ept, ept, cargocinco, cargozero, cargozero, cargozero);
	strcat(query, partquery);

	format(partquery, sizeof(partquery), " '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",  cargozero, cargozero, cargozero, cargozero, cargozero, cargozero, cargozero, cargozero, cargozero, cargozero, cargozero, cargozero);
	strcat(query, partquery);
	mysql_function_query(ConnectMYSQL,query,true,"r@MySQL_CreateFaction","d",playerid);  

    new facid = fmembro[playerid];
    FactionInfo[facid][facname][0] = EOS; // clear string
    strcat(FactionInfo[facid][facname], name, 32); // 32 is the size of facname[32] in enum
	// https://sampforum.blast.hk/showthread.ph...5.39964125	// o de cima jб й igual o de baixo
	// FactionInfo[facid][facname] = name;
    FactionInfo[facid][membro1] = seunome;
    FactionInfo[facid][membro2] = ept;
    FactionInfo[facid][membro3] = ept;
    FactionInfo[facid][membro4] = ept;
    FactionInfo[facid][membro5] = ept;
    FactionInfo[facid][membro6] = ept;
    FactionInfo[facid][membro7] = ept;
    FactionInfo[facid][membro8] = ept;
    FactionInfo[facid][membro9] = ept;
    FactionInfo[facid][membro10] = ept;
    FactionInfo[facid][membro11] = ept;
    FactionInfo[facid][membro12] = ept;
    FactionInfo[facid][membro13] = ept;
    FactionInfo[facid][membro14] = ept;
    FactionInfo[facid][membro15] = ept;

    FactionInfo[facid][cargo1] = cargocinco;
    FactionInfo[facid][cargo2] = cargozero;
    FactionInfo[facid][cargo3] = cargozero;
    FactionInfo[facid][cargo4] = cargozero;
    FactionInfo[facid][cargo5] = cargozero;
    FactionInfo[facid][cargo6] = cargozero;
    FactionInfo[facid][cargo7] = cargozero;
    FactionInfo[facid][cargo8] = cargozero;
    FactionInfo[facid][cargo9] = cargozero;
    FactionInfo[facid][cargo10] = cargozero;
    FactionInfo[facid][cargo11] = cargozero;
    FactionInfo[facid][cargo12] = cargozero;
    FactionInfo[facid][cargo13] = cargozero;
    FactionInfo[facid][cargo14] = cargozero;
    FactionInfo[facid][cargo15] = cargozero;
    return 1;
}

public r@MySQL_CreateFaction(playerid) {
    new novafacid = cache_insert_id(ConnectMYSQL);
    fmembro[playerid] = novafacid;
    fcargo[playerid] = 5;
    GivePlayerMoneyEx(playerid,-500000);
    SendClientMessage(playerid,-1,"Faction successfully created!");
    return 1;
}
Someone can fix it to me? Please
Reply
#2

PHP код:
    new partquery[500];
    
format(partquerysizeof(partquery), "INSERT INTO `factions` VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, %d,"nameseunomeepteptepteptepteptepteptepteptepteptepteptcargocincocargozerocargozerocargozero);
    
strcat(querypartquery);
    
format(partquerysizeof(partquery), " %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)",  cargozerocargozerocargozerocargozerocargozerocargozerocargozerocargozerocargozerocargozerocargozerocargozero);
    
strcat(querypartquery); 
If this didn't work, show me the mysql_log file.
Reply
#3

Quote:
Originally Posted by PawnHunter
Посмотреть сообщение
PHP код:
    new partquery[500];
    
format(partquerysizeof(partquery), "INSERT INTO `factions` VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, %d,"nameseunomeepteptepteptepteptepteptepteptepteptepteptcargocincocargozerocargozerocargozero);
    
strcat(querypartquery);
    
format(partquerysizeof(partquery), " %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)",  cargozerocargozerocargozerocargozerocargozerocargozerocargozerocargozerocargozerocargozerocargozerocargozero);
    
strcat(querypartquery); 
If this didn't work, show me the mysql_log file.
Don't work

Код:
[04:37:04] [DEBUG] mysql_tquery - connection: 1, query: "SELECT COUNT(*) AS `exists` FROM factions WHERE facname='Teste'", callback: "r@MySQL_CheckFaction", format: "ds"
[04:37:04] [DEBUG] CMySQLQuery::Execute[r@MySQL_CheckFaction] - starting query execution
[04:37:04] [DEBUG] CMySQLQuery::Execute[r@MySQL_CheckFaction] - query was successfully executed within 0.607 milliseconds
[04:37:04] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[04:37:04] [DEBUG] Calling callback "r@MySQL_CheckFaction"..
[04:37:04] [DEBUG] cache_get_field_content - row: 0, field_name: "exists", connection: 1, max_len: 11
[04:37:04] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "exists", data: "0"
[04:37:04] [DEBUG] mysql_tquery - connection: 1, query: "INSERT INTO `factions` VALUES ('Teste', '[7M]Lucca', 'Empty', 'E", callback: "r@MySQL_CreateFaction", format: "d"
[04:37:04] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[04:37:04] [DEBUG] CMySQLQuery::Execute[r@MySQL_CreateFaction] - starting query execution
[04:37:04] [ERROR] CMySQLQuery::Execute[r@MySQL_CreateFaction] - (error #1136) Column count doesn't match value count at row 1
[04:37:04] [DEBUG] CMySQLQuery::Execute[r@MySQL_CreateFaction] - error will be triggered in OnQueryError
[04:37:04] [DEBUG] Calling callback "OnQueryError"..
+rep to try help me
Reply
#4

May I see your columns? table columns?
The Error says you inserting some values inside a column which isn't in the table.
Reply
#5

[04:37:04] [ERROR] CMySQLQuery::Execute[r@MySQL_CreateFaction] - (error #1136) Column count doesn't match value count at row 1

I'm not even sure if you can insert this way, but if you can the error is simply telling you that you are sending too many variables into the table (example: you have ID, name, pass in the table, you are sending ID, name, pass and money into it.)
Reply
#6

Quote:
Originally Posted by PawnHunter
Посмотреть сообщение
May I see your columns? table columns?
The Error says you inserting some values inside a column which isn't in the table.
Help me to put all, i try but line is so long
http://imgur.com/KWTVtdu

Quote:
Originally Posted by PrO.GameR
Посмотреть сообщение
[04:37:04] [ERROR] CMySQLQuery::Execute[r@MySQL_CreateFaction] - (error #1136) Column count doesn't match value count at row 1

I'm not even sure if you can insert this way, but if you can the error is simply telling you that you are sending too many variables into the table (example: you have ID, name, pass in the table, you are sending ID, name, pass and money into it.)
I think i need insert on this mode
Код:
                format(query, sizeof(query), "INSERT INTO `accounts` (`Username`, `Senha`, `IP`) VALUES ('%s', '%s', '%s')", GetName(playerid), pInfo[playerid][pSenha], ip);
But i try and my lines is so long, can u help me to fix it?





--------------------------------------------------------------------------------------------------------------------------------------------

Код:
	format(query, sizeof(query), "INSERT INTO `factions` (`facname`, `membro1`, `membro2`, `membro3`, `membro4`, `membro5`, `membro6`, `membro7`, `membro8`, `membro9`, `membro10`, `membro11`, `membro12`, `membro13`, `membro14`, `membro15`, `cargo1`, `cargo2`, `cargo3`, `cargo4`, `cargo5`, `cargo6`, `cargo7`, `cargo8`, `cargo9`, `cargo10`, `cargo11`, `cargo12`, `cargo13`, `cargo14`, `cargo15`)
	VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')"
	, 
		name, 
		seunome, 
		ept, 
		ept, 
		ept, 
		ept, 
		ept, 
		ept, 
		ept, 
		ept, 
		ept, 
		ept, 
		ept, 
		ept, 
		ept, 
		ept, 
		cargocinco, 
		cargozero, 
		cargozero, 
		cargozero, 
		cargozero, 
		cargozero, 
		cargozero, 
		cargozero, 
		cargozero, 
		cargozero, 
		cargozero, 
		cargozero, 
		cargozero, 
		cargozero, 
		cargozero, 
		cargozero);
	mysql_function_query(ConnectMYSQL,query,true,"r@MySQL_CreateFaction","d",playerid);
Reply
#7

help me guys, please
Reply
#8

You don't read or follow the advice given to you by me and others, so tell me why we should still bother? I've told you at least once in another topic that you should restructure your database, and I've given clear instructions and screenshots that show how to do it. If you were to store 1000 cargo pieces, what would you do? Create 1000 columns? That's just crazy and completely illogical.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)