MySQL checking DB help
#2

Execute the query in PHPMyAdmin itself (assuming you're on windows). That usually eliminates the invalid SQL.

As for the reason;

See below code. Explained as i fixed (hopefully). If you have any issues, let me know.

pawn Код:
public CheckForRegister(name[], playerid)
{
    new query[100];
    format(query,sizeof(query),"SELECT * FROM `players` WHERE `username`='%s' LIMIT 1", name);
    return mysql_tquery(handle, query, "IsPlayerRegistered", "i", playerid);
    /*


        mysql_tquery(connectionHandle, query[], callback[] = "", format[] = "", {Float,_:...});
        mysql_pquery(connectionHandle, query[], callback[] = "", format[] = "", {Float,_:...});
   
        The above need to be called outside of the function. See IsPlayerRegistered(playerid) as an example.

        IsPlayerRegistered - callback[]
        "i"                - specificer (i, d, s for example)
        playerid           - {Float,_:...} arguments (vehicleid, playerid, targetid etc)


    */

}

forward public IsPlayerRegistered(playerid); // see the specifiers i used above ("i" and playerid, being the people's account we're checking for)
public IsPlayerRegistered(playerid)
{
    new rows, fields;
    cache_get_data(rows, fields, handle);
 
    if(rows) /* NOTE: Since you're checking if there's an account, you CAN use cache_num_rows(); if you're fussy about line count */
    {
        ShowPlayerDialog(playerid, DIALOG_PLAYER_ADD, DIALOG_STYLE_INPUT, "Register", "{FFFFFF}Username in use.\nChoose another name:", "Next", "");
    }
    else
    {
            // nothing found
    }
    return 1;
}
Reply


Messages In This Thread
MySQL checking DB help - by HidroDF - 14.03.2017, 20:06
Re: MySQL checking DB help - by DobbysGamertag - 14.03.2017, 20:31

Forum Jump:


Users browsing this thread: 2 Guest(s)