SQL->GetData couldn't retrive a value correctly when use with date_format()

AnnieRuru

~~Cute~Cute~Scripter~~
Messages
1,677
Points
0
Location
your next door ~
Discord
AnnieRuru#1609
Github
AnnieRuru
Emulator
Client Version
2019-05-30aRagexeRE
ACMD(test1) { int account_id; char player_name[NAME_LENGTH]; if ( SQL->Query( map->mysql_handle, "select name, account_id from `char` where account_id = 2000000" ) == SQL_ERROR ) { Sql_ShowDebug( map->mysql_handle ); return false; } else if ( SQL->NextRow( map->mysql_handle ) == SQL_SUCCESS ) { char *data; if ( SQL->GetData( map->mysql_handle, 0, &data, NULL ) == SQL_SUCCESS ) safestrncpy( player_name, data, NAME_LENGTH ); if ( SQL->GetData( map->mysql_handle, 1, &data, NULL ) == SQL_SUCCESS ) account_id = atoi(data); SQL->FreeResult( map->mysql_handle ); } else { SQL->FreeResult( map->mysql_handle ); return false; } safesnprintf( atcmd_output, 255, "%s %d", player_name, account_id ); clif->message( fd, atcmd_output ); return true;}ACMD(test2) { char strings1[40], strings2[40]; if ( SQL->Query( map->mysql_handle, "select lastlogin, date_format( lastlogin,' %W %l %i %p') from login where account_id = 2000000" ) == SQL_ERROR ) { Sql_ShowDebug( map->mysql_handle ); return false; } else if ( SQL->NextRow( map->mysql_handle ) == SQL_SUCCESS ) { char *data; size_t len; if ( SQL->GetData( map->mysql_handle, 0, &data, &len ) == SQL_SUCCESS ) safestrncpy( strings1, data, 40 );// if ( SQL->GetData( map->mysql_handle, 1, &data, NULL ) == SQL_SUCCESS ) { if ( SQL->GetData( map->mysql_handle, 1, &data, &len ) == SQL_SUCCESS ) { safestrncpy( strings2, data, 40 ); ShowDebug( "%s %s", data, strings2 ); } SQL->FreeResult( map->mysql_handle ); } else { SQL->FreeResult( map->mysql_handle ); return false; } safesnprintf( atcmd_output, 255, "%s %s", strings1, strings2 ); clif->message( fd, atcmd_output ); return true;}
Code:
		ACMD_DEF(test1),		ACMD_DEF(test2),
@test1 return

AnnieRuru 2000000

@test2 return

2014-09-10 16:41:34 W 1226864 0012B3A8

????

why is "date_format( lastlogin,' %W %l %i %p')" gives funny numbers ?

I couldn't figure out why using the same syntax, same script, just different query can lead to different result ?

and the exact same query, when use in a npc, it doesn't bug at all

Code:
-	script	kjsdhfkjsdhf	-1,{OnInit:	query_sql "select lastlogin, date_format( lastlogin,' %W %l %i %p') from login where account_id = 2000000", .@time1$, .@time2$;	announce .@time1$ +" "+ .@time2$, 0;}
 
Last edited by a moderator:
Back
Top