Little MySql Error
#1

Error:

Код:
[01:34:14] [ERROR] CMySQLQuery::Execute - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ', `Membro6` = '', `Membro7` = '', `Membro8` =  '', `Membro9` =' at line 1

The error should come from here:

Код:
SaveGang(id)
{
	new querygang[1024], tempquery[250 char];

	format(querygang, sizeof(querygang), "UPDATE `gangs` SET `Nome` = '%s',  `Lider` = '%s', `Membro0` = '%s', `Membro1` = '%s', `Membro2` =  '%s', `Membro3` = '%s', `Membro4` =  '%s', `Membro5` = '%s',",
	Gang[id][gangname], Gang[id][Lider], Gang[id][Membro0], Gang[id][Membro1], Gang[id][Membro2], Gang[id][Membro3], Gang[id][Membro4], Gang[id][Membro5]);

	format(tempquery, sizeof(tempquery), "%s `Membro6` = '%s', `Membro7` = '%s', `Membro8` =  '%s', `Membro9` = '%s', `Kills` = '%d', `Deaths` = '%d', `GCor` = '%s' WHERE `id` = '%d';",
	querygang, Gang[id][Membro6], Gang[id][Membro7], Gang[id][Membro8], Gang[id][Membro9], Gang[id][Kills], Gang[id][Deaths], Gang[id][GCor], id);
	strcat(querygang, tempquery, sizeof querygang);
	mysql_query(mysql, querygang, false);
	return 1;
}
Reply
#2

can you try this?

pawn Код:
SaveGang(id)
{
    new querygang[1024], tempquery[2048];

    format(querygang, sizeof(querygang), "UPDATE `gangs` SET `Nome` = '%s',  `Lider` = '%s', `Membro0` = '%s', `Membro1` = '%s', `Membro2` =  '%s', `Membro3` = '%s', `Membro4` =  '%s', `Membro5` = '%s',",
    Gang[id][gangname], Gang[id][Lider], Gang[id][Membro0], Gang[id][Membro1], Gang[id][Membro2], Gang[id][Membro3], Gang[id][Membro4], Gang[id][Membro5]);

    format(tempquery, sizeof(tempquery), "%s `Membro6` = '%s', `Membro7` = '%s', `Membro8` =  '%s', `Membro9` = '%s', `Kills` = '%d', `Deaths` = '%d', `GCor` = '%s' WHERE `id` = '%d';",
    querygang, Gang[id][Membro6], Gang[id][Membro7], Gang[id][Membro8], Gang[id][Membro9], Gang[id][Kills], Gang[id][Deaths], Gang[id][GCor], id);
    strcat(querygang, tempquery, sizeof querygang);
    mysql_query(mysql, querygang, false);
    return 1;
}
try it and tell me if it worked
Reply
#3

pawn Код:
SaveGang(id)
{
    new querygang[1024];
    format(querygang, sizeof(querygang), "UPDATE `gangs` SET `Nome` = '%s',  `Lider` = '%s', `Membro0` = '%s', `Membro1` = '%s', `Membro2` =  '%s', `Membro3` = '%s', `Membro4` =  '%s', `Membro5` = '%s',", Gang[id][gangname], Gang[id][Lider], Gang[id][Membro0], Gang[id][Membro1], Gang[id][Membro2], Gang[id][Membro3], Gang[id][Membro4], Gang[id][Membro5]);
    format(querygang, sizeof(querygang), "%s `Membro6` = '%s', `Membro7` = '%s', `Membro8` =  '%s', `Membro9` = '%s', `Kills` = '%d', `Deaths` = '%d', `GCor` = '%s' WHERE `id` = '%d';", querygang, Gang[id][Membro6], Gang[id][Membro7], Gang[id][Membro8], Gang[id][Membro9], Gang[id][Kills], Gang[id][Deaths], Gang[id][GCor], id);
    mysql_query(mysql, querygang, false);
    return 1;
}
No need for strcat as you're already including the first part of the string at the beginning of the second one.
Reply
#4

EDIT: FIXED had to rename from the database Cor with GCor now everything is fine, thank you (i use second code)

Thank you for help but i still get error, with first code you told me to try i get the samme error i had before and with the second code i get this:

Код:
[11:53:00] [ERROR] CMySQLQuery::Execute - (error #1054) Unknown column 'GCor' in 'field list'
Reply
#5

After restarting the server i find again a mysql error on my gamemode:

Код:
[12:32:16] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('0')
[12:32:16] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('1')
[12:32:16] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('2')
[12:32:16] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('3')
[12:32:16] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('4')
[12:32:16] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('5')
[12:32:16] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('6')
[12:32:16] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('7')
[12:32:16] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('8')
[12:32:16] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('9')
[12:32:16] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('10')
[12:32:16] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('11')
[12:32:16] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('12')
[12:32:16] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('13')
[12:32:16] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('14')
[12:32:16] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('15')
[12:32:16] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('16')
[12:32:16] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('17')
I didn't find this error on error logs i had before, whats going on now ?
Reply
#6

When you get SQL syntax errors that are not obvious, it's better to print the finished SQL command (after formatting) so you can read it. Then it's easier to spot the error, and you might not need to change code, just the sql command.

I'm not familiar with the MySQL plugin any more, but from the looks of the new errors you are calling "GetRowData" (pawn version if there is one) with an invalid index.

For example only 1 row is returned (from a SELECT query) but you are trying to get a second row (or column that doesn't exist). It's just a guess, but if the error messages are accurate, that's what your doing.

EDIT: And don't forget if you change the name of a column you need to alter ALL of your SQL commands that use said column.
Reply
#7

Thank you man +rep, this helped me Lock the theard, i will rep up everyone helped me in this topic, really thanks!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)