MySQL Query String
#1

pawn Код:
new sqldb, query[1000];
I have defined the connection handle(sqldb) and the query string(query[1000])
pawn Код:
stock PlayerExists(playerid)
{
    format(query, sizeof(query), "SELECT 'accname' FROM 'accounts' WHERE 'accname' = '%s' LIMIT 1", GetName(playerid));
    mysql_query(query);
    mysql_store_result();
    new rows = mysql_num_rows();
    if(!rows)
    {
        ShowPlayerDialog(playerid, REGISTER_DIALOG, DIALOG_STYLE_INPUT, "Register", "Welcome to MySQL Gamemode!\nPlease register to continue!", "Register", "Disconnect");
    }
    if(rows == 1)
    {
        ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_PASSWORD, "Login", "Welcome back!\nPlease login to continue!", "Login", "Disconnect");
    }
    return 1;
}
But when I use query on the line 53(this line)
pawn Код:
mysql_query(query);
I get the error: error 035: argument type mismatch (argument 1)
Reply
#2

Are you using BlueG's plugin?
Which version?

The latest versions (R33 and higher) have the connectionhandle as first argument.
Your query is a string, while the connectionhandle is an integer.
Reply
#3

I'm using Blue G's R37 MySQL plugin...


EDIT: thanks, I just added
pawn Код:
mysql_query(sqldb, query);
Reply
#4

More help needed!!!!! I'm learning MySQL

pawn Код:
stock CreateAccountID(playerid) // To create a MySQL Database ID for the account
{
    PlayerInfo[playerid][pSQLID] = cache_insert_id();
    return 1;
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    format(query, sizeof(query), "UPDATE `accounts` SET `sqlid` = '%i' SET 'accname' = '%s' WHERE 1", CreateAccountID(playerid), GetName(playerid));
    mysql_query(sqldb, query);
    return 1;
}
But it doesn't save anything. Help please
Reply
#5

You need first to insert new rows by using the INSERT query command. If your SQLID column is auto incremental then it'll be increased automatically.
Reply
#6

Could you explain me that on xfire or here(if you have xfire I would prefer xfire.
Reply
#7

Quote:
Originally Posted by venomlivno8
Посмотреть сообщение
Could you explain me that on xfire or here(if you have xfire I would prefer xfire.
Sure.

Step 1 - ****** "SQL Insert"
Step 2 - Enter first link
Step 3 - Read and learn.

I'll do it for you this time.
http://www.w3schools.com/sql/sql_insert.asp
Reply
#8

Thanks, m8!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)