mysql error
#1

Hello, got a problem with dynamic text labels. It fucks up my registration system.
I cant do the tutorial and when I make a label that says: /maketext test red.
It will show up as tred. as it only will make the first letter that I chose.

This is the create table on ongamemodeinit:

Код:
mysql_query(conn,"CREATE TABLE IF NOT EXISTS textlabel(t_id_ INT(20),t_text VARCHAR(228),t_color_ VARCHAR(23),t_x float(20),t_y float(20),t_z float(20))");
The actual command:

Код:
COMMAND:maketext(playerid,params[])
{
    if(sscanf(params,"s[128]s[24]",params[0],params[1]))
        return SendClientMessage(playerid,-1,"[Usage]: /maketext [Text-string] [color (red/blue/orange/green)]");
    if(tInfo[playerid][t_id] >= MAX_TEXT)
        return SendClientMessage(playerid,-1,"[Error]: you cannot to create more textlabels, because you create a many textlabels, please delete some textlables!");
    new
        gQuery[356],
        Float: gPos[MAX_PLAYERS][3];
	tInfo[playerid][t_id] ++;
    GetPlayerPos(playerid,gPos[playerid][0],gPos[playerid][1],gPos[playerid][2]);
    format(gQuery, sizeof(gQuery), "INSERT INTO `textlabel` (`t_id_`,`t_text`,`t_color_`,`t_x`,`t_y`,`t_z`) VALUES ('%d'),('%s'),('%s'),('%f'),('%f'),('%f')", tInfo[playerid][t_id],"red",gPos[playerid][0],gPos[playerid][1],gPos[playerid][2]);
	mysql_function_query(conn, gQuery, false, "OnQuerySend", "", playerid); // 67
	for(new i,j = MAX_TEXT; i != j; i++) tInfo[i][t_id] ++;
    if(!strcmp(params[1],"blue",true)) tInfo[playerid][t_label] = Create3DTextLabel(params[0],0x1492EDFF,gPos[playerid][0],gPos[playerid][1],gPos[playerid][2],40.0,0,0);
    if(!strcmp(params[1],"red",true)) tInfo[playerid][t_label] = Create3DTextLabel(params[0],0xED1414FF,gPos[playerid][0],gPos[playerid][1],gPos[playerid][2],40.0,0,0);
    if(!strcmp(params[1],"green",true)) tInfo[playerid][t_label] = Create3DTextLabel(params[0],0x25ED14FF,gPos[playerid][0],gPos[playerid][1],gPos[playerid][2],40.0,0,0);
    if(!strcmp(params[1],"orange",true)) tInfo[playerid][t_label] = Create3DTextLabel(params[0],0xED9614FF,gPos[playerid][0],gPos[playerid][1],gPos[playerid][2],40.0,0,0);
    SendClientMessage(playerid,-1,"[Success]: you successuflly created a textlabel!");
    return 1;
}
Loading the textdraws from the db code:

Код:
forward _loadTextLabel();
public _loadTextLabel()
{
        for(new i,j = MAX_TEXT; i != j; i++)
        {
                tInfo[i][t_id] = cache_get_field_content_int(0,"t_id_",conn);
				cache_get_field_content(0,"t_text",tInfo[i][t_string],conn);
                cache_get_field_content(0,"t_color_",tInfo[i][t_color],conn);
                tInfo[i][t_postion][0] = cache_get_field_content_float(0,"t_x",conn);
                tInfo[i][t_postion][1] = cache_get_field_content_float(0,"t_y",conn);
                tInfo[i][t_postion][2] = cache_get_field_content_float(0,"t_z",conn);
        }
        SetTimer("_loadTextAllTextLabel",2000,false);
        return 1;
}

forward _loadTextAllTextLabel();
public _loadTextAllTextLabel()
{
        for(new i,j = MAX_TEXT; i != j; i++)
        {
                if(!strcmp(tInfo[i][t_color],"blue",true)) tInfo[i][t_label] = Create3DTextLabel(tInfo[i][t_string],0x1492EDFF,tInfo[i][t_postion][0],tInfo[i][t_postion][1],tInfo[i][t_postion][2],40.0,0,0);
                if(!strcmp(tInfo[i][t_color],"red",true)) tInfo[i][t_label] = Create3DTextLabel(tInfo[i][t_string],0xED1414FF,tInfo[i][t_postion][0],tInfo[i][t_postion][1],tInfo[i][t_postion][2],40.0,0,0);
                if(!strcmp(tInfo[i][t_color],"green",true)) tInfo[i][t_label] = Create3DTextLabel(tInfo[i][t_string],0x25ED14FF,tInfo[i][t_postion][0],tInfo[i][t_postion][1],tInfo[i][t_postion][2],40.0,0,0);
                if(!strcmp(tInfo[i][t_color],"orange",true)) tInfo[i][t_label] = Create3DTextLabel(tInfo[i][t_string],0xED9614FF,tInfo[i][t_postion][0],tInfo[i][t_postion][1],tInfo[i][t_postion][2],40.0,0,0);
        }
        return 1;
}
Mysql error:

Quote:

[12:45:52] [ERROR] CMySQLQuery::Execute[OnQuerySend()] - (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 ''€Ћ' at line 1
[12:48:15] [ERROR] CMySQLQuery::Execute[OnQuerySend()] - (error #1136) Column count doesn't match value count at row 1

Using the BlueG R33 mysql plugin.

Whats wrong? Any help is appreciated!
Reply
#2

pawn Код:
format(gQuery, sizeof(gQuery), "INSERT INTO `textlabel` (`t_id_`,`t_text`,`t_color_`,`t_x`,`t_y`,`t_z`) VALUES ('%d'),('%s'),('%s'),('%f'),('%f'),('%f')", tInfo[playerid][t_id],"red",gPos[playerid][0],gPos[playerid][1],gPos[playerid][2]);
You need 6 parameters there, and you only pass 5, also it's %f and %d, not '%f' and '%d'.

So, it would be:

pawn Код:
VALUES (%d, '%s', '%s', %f, %f, %f)
Reply
#3

oh, thanks
Reply
#4

Alright, tested it. Still same issue.

And same error:
Quote:

[13:45:45] [ERROR] CMySQLQuery::Execute[OnQuerySend()] - (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 ')' at line 1

Reply
#5

And actual query format? Idk if you changed something.
Reply
#6

Edited command:

Код:
COMMAND:maketext(playerid,params[])
{
    if(sscanf(params,"s[128]s[24]",params[0],params[1]))
        return SendClientMessage(playerid,-1,"[Usage]: /maketext [Text-string] [color (red/blue/orange/green)]");
    if(tInfo[playerid][t_id] >= MAX_TEXT)
        return SendClientMessage(playerid,-1,"[Error]: you cannot to create more textlabels, because you create a many textlabels, please delete some textlables!");
    new
        gQuery[356],
        Float: gPos[MAX_PLAYERS][3];
	tInfo[playerid][t_id] ++;
    GetPlayerPos(playerid,gPos[playerid][0],gPos[playerid][1],gPos[playerid][2]);
    format(gQuery, sizeof(gQuery), "INSERT INTO `textlabel` (`t_id_`,`t_text`,`t_color_`,`t_x`,`t_y`,`t_z`) VALUES (%d, '%s', '%s', %f, %f, %f)", tInfo[playerid][t_id],tInfo[playerid][t_string],tInfo[playerid][t_color],gPos[playerid][0],gPos[playerid][1],gPos[playerid][2]);
	mysql_function_query(conn, gQuery, false, "OnQuerySend", "", playerid); // 67
	for(new i,j = MAX_TEXT; i != j; i++) tInfo[i][t_id] ++;
    if(!strcmp(params[1],"blue",true)) tInfo[playerid][t_label] = Create3DTextLabel(params[0],0x1492EDFF,gPos[playerid][0],gPos[playerid][1],gPos[playerid][2],40.0,0,0);
    if(!strcmp(params[1],"red",true)) tInfo[playerid][t_label] = Create3DTextLabel(params[0],0xED1414FF,gPos[playerid][0],gPos[playerid][1],gPos[playerid][2],40.0,0,0);
    if(!strcmp(params[1],"green",true)) tInfo[playerid][t_label] = Create3DTextLabel(params[0],0x25ED14FF,gPos[playerid][0],gPos[playerid][1],gPos[playerid][2],40.0,0,0);
    if(!strcmp(params[1],"orange",true)) tInfo[playerid][t_label] = Create3DTextLabel(params[0],0xED9614FF,gPos[playerid][0],gPos[playerid][1],gPos[playerid][2],40.0,0,0);
    SendClientMessage(playerid,-1,"[Success]: you successuflly created a textlabel!");
    return 1;
}
Reply
#7

Try:

pawn Код:
format(gQuery, sizeof(gQuery), "INSERT INTO textlabel(`t_id_`,`t_text`,`t_color_`,`t_x`,`t_y`,`t_z`) VALUES ('%d', '%s', '%s', '%f', '%f', '%f')", tInfo[playerid][t_id],tInfo[playerid][t_string],tInfo[playerid][t_color],gPos[playerid][0],gPos[playerid][1],gPos[playerid][2]);
Reply
#8

Still same issue.

This is how it looks in the database:

Reply
#9

This is the new command:

Код:
COMMAND:maketext(playerid,params[])
{
    if(sscanf(params,"s[228]",params[0]))
        return SendClientMessage(playerid,-1,"[Usage]: /maketext [Text-string] red");
    if(tInfo[playerid][t_id] >= MAX_TEXT)
        return SendClientMessage(playerid,-1,"[Error]: you cannot to create more textlabels, because you create a many textlabels, please delete some textlables!");
    new
        gQuery[356],
        Float: gPos[MAX_PLAYERS][3];
	tInfo[playerid][t_id] ++;
    GetPlayerPos(playerid,gPos[playerid][0],gPos[playerid][1],gPos[playerid][2]);
	format(gQuery, sizeof(gQuery), "INSERT INTO textlabel(`t_id_`,`t_text`,`t_color_`,`t_x`,`t_y`,`t_z`) VALUES ('%d', '%s', '%s', '%f', '%f', '%f')", tInfo[playerid][t_id],tInfo[playerid][t_string],"0xED1414FF",gPos[playerid][0],gPos[playerid][1],gPos[playerid][2]);
	mysql_function_query(conn, gQuery, false, "OnQuerySend", "", playerid); // 67
	for(new i,j = MAX_TEXT; i != j; i++) tInfo[i][t_id] ++;
    tInfo[playerid][t_label] = Create3DTextLabel(params[0],0xED1414FF,gPos[playerid][0],gPos[playerid][1],gPos[playerid][2],40.0,0,0);
    SendClientMessage(playerid,-1,"[Success]: you successuflly created a textlabel!");
    return 1;
}
The color gets saved now. But the text dont.
Reply
#10

Fixed it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)