mysql_query - argument type mismatch error
#1

error 035: argument type mismatch (argument 1)

Code:

Код:
CheckAccountExists(account[])
{
	new string[128];
	format(string, sizeof(string), "SELECT * FROM Users WHERE Name = '%s'", account);
	mysql_query(string);  // This line

	mysql_store_result();
	new value;
	value = mysql_num_rows();
	mysql_free_result();
	return value;
}
Reply
#2

PHP код:
CheckAccountExists(account[])
{
    new 
string[128];
    
format(stringsizeof(string), "SELECT * FROM Users WHERE Name = %s"account);
    
mysql_query(string);  // This line
    
mysql_store_result();
    new 
value;
    
value mysql_num_rows();
    
mysql_free_result();
    return 
value;

Try it without the single quotes
Reply
#3

Still the same error. It's something to do with this line...

PHP код:
    mysql_query(string); 
Reply
#4

Can you show us where you use the CheckAccountExists Function?
Reply
#5

EDIT:
mysql_query has 2 mandatory arguments.
The first : Connection handle
The second : The query

https://sampwiki.blast.hk/wiki/MySQL/R33#mysql_query

PHP код:
mysql mysql_connect("host""user""database""pass");
mysql_query(mysqlquery); 
Reply
#6

So this is my connection handle...

PHP код:
CheckMySQL()
{
        
mysql_connect(MYSQL_HOSTMYSQL_USERMYSQL_DBMYSQL_PASS);

So I changed the code to

PHP код:
CheckAccountExists(account[])
{
    new 
string[128];
    
format(stringsizeof(string), "SELECT * FROM Users WHERE Name = '%s'"account);
    
mysql_query(checkmysqlstring);  // This line

    
mysql_store_result();
    new 
value;
    
value mysql_num_rows();
    
mysql_free_result();
    return 
value;

and i still get the same error...
Reply
#7

Change your connection handle to this
PHP код:
CheckMySQL()
{
        return 
mysql_connect(MYSQL_HOSTMYSQL_USERMYSQL_DBMYSQL_PASS);

On the top of the script just below the function add,

PHP код:
new MySql CheckMySQL(); 
Then change your Function to this:

PHP код:
CheckAccountExists(account[])
{
    new 
string[128];
    
format(stringsizeof(string), "SELECT * FROM Users WHERE Name = '%s'"account);
    
mysql_query(MySqlstring);  // This line
    
mysql_store_result();
    new 
value;
    
value mysql_num_rows();
    
mysql_free_result();
    return 
value;

Reply
#8

After a few minutes of struggling...

This causes the Pawn Compiler Library to stop working...

PHP код:
new MySql CheckMySQL(); 
Reply
#9

EDIT: This is probably where the errors come from...

PHP код:
SavePlayer(playerid)
{
    if(!
PlayerLogged[playerid])
        return 
0;

    
UserStats[playerid][Money] = GetPlayerMoney(playerid);


    
CheckMySQL();

    new 
string[256];
    
format(stringsizeof(string), "UPDATE Users SET Password='%s',Money='%d' WHERE Name='%s'"UserStats[playerid][Password], UserStats[playerid][Money], UserStats[playerid][Name]);
    
mysql_query(MySqlstring);
    return 
1;

Reply
#10

PHP код:
new MySql;
CheckMySQL()
{
        
MySql mysql_connect(MYSQL_HOSTMYSQL_USERMYSQL_DBMYSQL_PASS);

Try This:
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)