SA-MP Forums Archive
sscanf warning: Invalid data length. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: sscanf warning: Invalid data length. (/showthread.php?tid=616209)



sscanf warning: Invalid data length. - CoachCarter - 02.09.2016

Sscanf is showing an error in server_logs, how can I fix it.

SSCANF ERROR:
Код:
sscanf warning: Invalid data length.
sscanf warning: Invalid character in data length.
This place creates error, but I don't know how to fix it:
Код:
`Moqmedeba` 'created'
Код:
format(query, sizeof(query),"INSERT INTO `logs_cctv`(`Name`, `CCTVName`, `Date`, `Moqmedeba`<--this creates warning) 
VALUES ('%s','%s','%s', 'created' <----along with this one)", sendername, name, datum);
mysql_tquery(handlesql, query);
Everything is good in mysql database. But Sscanf still keeps showing this warnings


Re: sscanf warning: Invalid data length. - Stinged - 02.09.2016

Show us the sscanf line, not format.


Re: sscanf warning: Invalid data length. - CoachCarter - 02.09.2016

Quote:
Originally Posted by Stinged
Посмотреть сообщение
Show us the sscanf line, not format.

there is no sscanf line, this is the whole creating script, and the error hides within that ('created') message when I remove it warning doesn't appear.
Код:
CreateCCTV(playerid, name[])
{
    new id = Iter_Free(CCTVIter);
    if(id != -1)
    {
        new
            Float: x, Float: y, Float: z;
        GetPlayerPos(playerid, x, y, z);

        CCTVInfo[id][cctv_X] = x;
        CCTVInfo[id][cctv_Y] = y;
        CCTVInfo[id][cctv_Z] = z;

        CCTVInfo[id][cctv_rotX] = 0.0;
        CCTVInfo[id][cctv_rotY] = 0.0;
        CCTVInfo[id][cctv_rotZ] = 0.0;

        CCTVInfo[id][cctv_VW] = GetPlayerVirtualWorld(playerid);
        CCTVInfo[id][cctv_Interior] = GetPlayerInterior(playerid);
        strcpy(CCTVInfo[id][cctv_Name], name, MAX_CCTV_NAME);

        CCTVInfo[id][cctv_Object] = CreateDynamicObject(1886, CCTVInfo[id][cctv_X], CCTVInfo[id][cctv_Y], CCTVInfo[id][cctv_Z], CCTVInfo[id][cctv_rotX], CCTVInfo[id][cctv_rotY], CCTVInfo[id][cctv_rotZ], CCTVInfo[id][cctv_VW]);

        Iter_Add(CCTVIter, id);
        mysql_tquery(handlesql, "INSERT INTO `cctv` (`cctv_x`) VALUES (0)", "OnCCTVCreated", "d", id);
        
        new sendername[MAX_PLAYER_NAME], query[128];
        format(sendername, sizeof(sendername), "%s", PlayerName(playerid));
  		GiveNameSpace(sendername);
		new year,month,day, datum[64];
		getdate(year, month, day);
		format(datum, sizeof(datum), "%d-%d-%d", year, month, day);
        format(query, sizeof(query),"INSERT INTO `logs_cctv`(`Name`, `CCTVName`, `Date`, `Moqmedeba`) VALUES ('%s','%s','%s', 'created')", sendername, name, datum);
		mysql_tquery(handlesql, query);
    }
    return id;
}



Re: sscanf warning: Invalid data length. - CoachCarter - 02.09.2016

All the way to the top


Re: sscanf warning: Invalid data length. - TORKQ - 02.09.2016

Maybe the format functions is somehow edited? Because i can't see any of sscanf functions here.
Didn't you try to use
Код:
mysql_format?



Re: sscanf warning: Invalid data length. - AndySedeyn - 02.09.2016

Unrelated to your issue, but sanitize your database inputs!
PHP код:
mysql_format(handle_varquerysizeof(query), "INSERT INTO table (someString) VALUES ('%e')"someString); 
The %e specifier only works with mysql_format and escapes strings for you.


Re: sscanf warning: Invalid data length. - CoachCarter - 03.09.2016

Still the same problem guys, tried everything


Re: sscanf warning: Invalid data length. - Stinged - 03.09.2016

Can you show us where you're calling CreateCCTV?
I mean also show some code around that.