[MYSQL] String not work ? -
mroq98 - 05.10.2015
Hello.
I have problem with log when i insert query to mysql do not show field "message".
I used global string "buffer" (new buffer[2000]
to formatted.
Stock:
Код:
WriteLog(message[], type)
{
new ttime[6];
getdate(ttime[0], ttime[1], ttime[2]);
gettime(ttime[3], ttime[4], ttime[5]);
format(buffer,sizeof(buffer),"INSERT INTO `Logs` SET `text` = '%s', `type_log` = '%d', `data` = '%d.%d.%d %02d:%02d:%02d'", message, type, ttime[3],ttime[4],ttime[5],ttime[0],ttime[1],ttime[2]);
mysql_query(buffer);
return 1;
}
Used:
Код:
public OnPlayerText(playerid, text[])
{
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
format(buffer,sizeof(buffer),"[CHAT] Player: %s, text: %s",pname,text);
WriteLog(buffer, 1);
return 1;
}
and it not work...
Код:
[10:54:55] CMySQLHandler::Query(INSERT INTO `Logs` SET `text` = '', `type_log` = '8', `data` = '10.54.55 2015:10:05') - Successfully executed.
[10:55:31] >> mysql_query( Connection handle: 1 )
but it work...
Код:
CMD:test2(playerid, params[]) return WriteLog(params, 0);
Код:
[10:51:39] CMySQLHandler::Query(INSERT INTO `Logs` SET `text` = 'helloooo', `type_log` = '0', `data` = '10.51.39 2015:10:05') - Successfully executed.
[10:51:41] >> mysql_query( Connection handle: 1 )
What is wrong? please help me.
Re: [MYSQL] String not work ? -
Prokill911 - 05.10.2015
1, You shouldn't be using '' When referencing an integer..
'' and "" references a string... strings must be contained so you're basically referencing an integer inside of a string when doing so.. meaning your integer has a string with it.. but in your case it doesn't..
so doing so is moot..
2, Your SQL Query should be something like:
mysql_function_query(g_mysql_handle,buffer ,false,"","");
I don't know what SQL You're using..
So it might be..
mysql_function_query(g_mysql_handle, buffer);
Example
Код:
WriteLog(message[], type)
{
new ttime[6];
getdate(ttime[0], ttime[1], ttime[2]);
gettime(ttime[3], ttime[4], ttime[5]);
format(buffer,sizeof(buffer),"INSERT INTO `Logs` SET `text` = '%s', `type_log` = %d, `data` = '%d.%d.%d %02d:%02d:%02d'", message, type, ttime[3],ttime[4],ttime[5],ttime[0],ttime[1],ttime[2]);
mysql_function_query(g_mysql_handle, buffer);
return 1;
}