[MSQL]Need help a bit.. with explaining how to do it right...
#1

So I need some explanation how can I update this to r39.. Because I need some seriuss help... With this funcition.
EROOR:
pawn Code:
error 017: undefined symbol "mysql_store_result"
error 017: undefined symbol "mysql_num_rows"
pawn Code:
new Query[200], escpname[24];
    mysql_real_escape_string(sendername, escpname);
    format(Query, sizeof(Query), "SELECT * FROM `players` WHERE `Name` = '%s'", escpname);
    mysql_query_ex(Query);
    mysql_store_result();
    if(mysql_num_rows() != 0) //If the user is found
    {
        gPlayerAccount[playerid] = 1;
    }
    else
    {
        gPlayerAccount[playerid] = 0;
    }
Reply
#2

Did you download Blueg-s mysql plugin, and a_mysql.inc update?
Reply
#3

Strings can be escaped with the '%e' specifier in your format.

These are functions you should take a look at:
mysql_format and mysql_tquery as well as the 'cache_' functions.

https://sampwiki.blast.hk/wiki/MySQL/R33
Reply
#4

as bible already said use %e to escapename here example

pawn Code:
stock LoginPlayer(playerid)
{
    new Query[200], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    mysql_format(MySQLConnection,Query, sizeof(Query), "SELECT * FROM `players` WHERE `Name` = '%e'", name);// in mysqlconnection put yours one
    mysql_tquery(MySQLConnection, Query, "OnPlayerLogin","d",playerid);
}

public OnPlayerLogin(playerid)
{  
    new Query[200], name[24], rows, fields;
    GetPlayerName(playerid, name , sizeof(name));
    cache_get_data(rows,fields,mysqlConnectin);
    if(rows) //If the user is found
    {
        gPlayerAccount[playerid] = 1;
    }
    else
    {
        gPlayerAccount[playerid] = 0;
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)