mysql_query argument type mismatch
#1

I am just trying to code a basic vip script, but i can't even compile it because of this error.

Here's the code that gives the error:

format(string, sizeof(string), "UPDATE `uyeler` SET vip = %d WHERE k_adi = '%s'", "1" , plname);
--->> mysql_query(string); <<---

Thank you all for your help.
Reply
#2

Код:
mysql_query(MySQL:handle, const query[], bool:use_cache = true)
In red, is what you are missing. If you don't know what is it, you may check some basic tutorial about MySQL for SAMP
Reply
#3

Every tutorial on the internet , It is always like this; mysql_query(string); . But I can't get rid of this error.
Here's all my code;
Quote:

#include <a_samp>
#include <a_mysql>
#include <sscanf>
#include <zcmd>

#define HOST "localhost"
#define SUSER "root"
#define PASS "123"
#define DB "area51"

Quote:

public OnGameModeInit()
{
mysql_connect("HOST", "USER", "DB", "PASS");
return 1;
}

Quote:

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

What should I change here ?
Reply
#4

PHP код:
//Assume You're using 39
new mysql;
CMD:setvip(playeridparams[])
{
    new 
targetidquery[126], pName[MAX_PLAYER_NAME];
    if(
targetid == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_ERROR"Invalid Player!");// A player could either be Connect/Disconnected.
    
if(sscanf(params"ud",targetid)) return SendClientMessage(playeridCOLOR_ERROR"{6EF83C}Kullanım:{FFFFFF} /setvip [playerid]");
    
GetPlayerName(targetidpNamesizeof(pName));
    
mysql_format(mysqlquerysizeof(query), "UPDATE uyeler SET vip = %d, WHERE k_adi = '%s'"1pName);// '' is more for %e and %s not %d. 
    
mysql_tquery(mysqlquery"""");
    return 
1;
}] 
Reply
#5

Quote:
Originally Posted by ISmokezU
Посмотреть сообщение
PHP код:
//Assume You're using 39
new mysql;
CMD:setvip(playeridparams[])
{
    new 
targetidquery[126], pName[MAX_PLAYER_NAME];
    if(
targetid == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_ERROR"Invalid Player!");// A player could either be Connect/Disconnected.
    
if(sscanf(params"ud",targetid)) return SendClientMessage(playeridCOLOR_ERROR"{6EF83C}Kullanım:{FFFFFF} /setvip [playerid]");
    
GetPlayerName(targetidpNamesizeof(pName));
    
mysql_format(mysqlquerysizeof(query), "UPDATE uyeler SET vip = %d, WHERE k_adi = '%s'"1pName);// '' is more for %e and %s not %d. 
    
mysql_tquery(mysqlquery"""");
    return 
1;
}] 
You forget the MySQL tag.
PHP код:
new MySQL:mysql 
Reply
#6

Thank you both so much for your help. Now I can compile and start the server but when I use /setvip 0
the server console says
Quote:

sscanf warning: Format specifier does not match parameter count.

and it doesn't update the vip field to 1. By the way I'm using R34
Reply
#7

Код:
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;
}
you asked sscanf to enter two params u and d (user id and integer) but you only asked for targetid where is your viplevel ? by the way if you ask me this in turkish in pm i can answer you in turkish too forum bans language other than english inside the posts
Reply
#8

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
You forget the MySQL tag.
PHP код:
new MySQL:mysql 
R39 doesn't require one.

PHP код:
new mysql
CMD:setvip(playeridparams[]) 

    new 
targetidquery[126], pName[MAX_PLAYER_NAME]; 
    if(
targetid == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_ERROR"Invalid Player!");
    if(
sscanf(params"i"targetid)) return SendClientMessage(playeridCOLOR_ERROR"{6EF83C}Kullanım:{FFFFFF} /setvip [playerid]"); 
    
GetPlayerName(targetidpNamesizeof(pName)); 
    
mysql_format(mysqlquerysizeof(query), "UPDATE uyeler SET vip = %d, WHERE k_adi = '%s'"1pName);
    
mysql_tquery(mysqlquery""""); 
    return 
1
}] 
Reply
#9

Now it doesn't give any errors but when i make myself vip it doesn't do anything at all. No errors, no reaction, nothing. No change in the database aswell.
It doesn't even warn when i use the wrong id.

Quote:

if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_ERROR, "Invalid Player!");

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)