I'm trying to teach myself dialogs and SQL, so I'm making a system where you can search for a player's info.
It gets stuck here, and everytime I type in my name either with or without the underscore, it returns the error message, even though my ID is 2 (so, not 0.)
Here's the code which should convert the name input to the character's ID and return the value...
Can anybody see any errors?
PHP Code:
Dialog:Panel_PlayerSearch(playerid, response, listitem, inputtext[])
{
if(!response) return PanelMain(playerid);
ReplaceSpaces(inputtext);
if(!NameCheck(inputtext)) return Panel_PlayerSearch(playerid);
new CharacterID = GetSQLIDFromName(inputtext);
if(CharacterID == 0)
{
SendErrorMessage(playerid, "Player not found!");
return Panel_PlayerSearch(playerid);
}
PlayerData[playerid][pPanel] = CharacterID;
Panel_PlayerInfo(playerid);
return 1;
}
Here's the code which should convert the name input to the character's ID and return the value...
PHP Code:
stock GetSQLIDFromName(name[])
{
new query[128], CharID;
mysql_format(SQL_CONNECT, query, sizeof(query), "SELECT ID FROM characters WHERE Username = '%e' LIMIT 1", name);
new Cache:result = mysql_query(SQL_CONNECT, query);
CharID = cache_get_field_content_int(0, "ID", SQL_CONNECT);
cache_delete(result);
return CharID;
}