mysql_query(MySQL:handle, const query[], bool:use_cache = true)
#include <a_samp> #include <a_mysql> #include <sscanf> #include <zcmd> #define HOST "localhost" #define SUSER "root" #define PASS "123" #define DB "area51" |
public OnGameModeInit() { mysql_connect("HOST", "USER", "DB", "PASS"); return 1; } |
CMD: setvip(playerid, params[]) { new targetid, query[126], pName[MAX_PLAYER_NAME]; if(sscanf(params, "ud",targetid)) { SendClientMessage(playerid, COLOR_ERROR, "{6EF83C}Kullanım:{FFFFFF} /setvip [playerid]"); return 1; } if(IsPlayerConnected(targetid)) { GetPlayerName(targetid, pName, sizeof(pName)); format(query, sizeof(query), "UPDATE `uyeler` SET vip = '%d', WHERE k_adi = '%s'", 1, pName); mysql_query(query); <-- error 35: argument type mismatch (argument 1) } return 1; } |
//Assume You're using 39
new mysql;
CMD:setvip(playerid, params[])
{
new targetid, query[126], pName[MAX_PLAYER_NAME];
if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_ERROR, "Invalid Player!");// A player could either be Connect/Disconnected.
if(sscanf(params, "ud",targetid)) return SendClientMessage(playerid, COLOR_ERROR, "{6EF83C}Kullanım:{FFFFFF} /setvip [playerid]");
GetPlayerName(targetid, pName, sizeof(pName));
mysql_format(mysql, query, sizeof(query), "UPDATE uyeler SET vip = %d, WHERE k_adi = '%s'", 1, pName);// '' is more for %e and %s not %d.
mysql_tquery(mysql, query, "", "");
return 1;
}]
PHP код:
|
new MySQL:mysql
sscanf warning: Format specifier does not match parameter count. |
CMD: setvip(playerid, params[]) { new targetid, query[126], pName[MAX_PLAYER_NAME]; if(sscanf(params, "ud",targetid)) //you asked sscanf to enter two params u and d (user id and integer) but you only asked for targetid where is your viplevel ? { SendClientMessage(playerid, COLOR_ERROR, "{6EF83C}Kullanım:{FFFFFF} /setvip [playerid]"); return 1; } if(IsPlayerConnected(targetid)) { GetPlayerName(targetid, pName, sizeof(pName)); format(query, sizeof(query), "UPDATE `uyeler` SET vip = '%d', WHERE k_adi = '%s'", 1, pName); mysql_query(query); <-- error 35: argument type mismatch (argument 1) } return 1; }
new mysql;
CMD:setvip(playerid, params[])
{
new targetid, query[126], pName[MAX_PLAYER_NAME];
if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_ERROR, "Invalid Player!");
if(sscanf(params, "i", targetid)) return SendClientMessage(playerid, COLOR_ERROR, "{6EF83C}Kullanım:{FFFFFF} /setvip [playerid]");
GetPlayerName(targetid, pName, sizeof(pName));
mysql_format(mysql, query, sizeof(query), "UPDATE uyeler SET vip = %d, WHERE k_adi = '%s'", 1, pName);
mysql_tquery(mysql, query, "", "");
return 1;
}]
if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_ERROR, "Invalid Player!"); |