Jump to content
  • 0
Sign in to follow this  
AnnieRuru

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

Question

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;}
		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

-	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;}

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.