31.12.2017, 09:33
Your query is fine. I wrote out an example for you:
Using the '%e' specifier escapes special characters in a string for the use in a SQL statement. It prevents backslashes to the following characters: \x00, \n, \r, \, ', " and \x1a.
cache_num_rows() returns the number of rows found in the query.
We loop through the rows in the instance there are more than one account associated with the IP.
PHP код:
stock SQL(playerid){
new
query[200];
mysql_format(MySQL, query, sizeof query, "SELECT * FROM accounts WHERE IP = '%e'", 127.0.0.1);
mysql_tquery(MySQL, query, "IPAddressQuery", "i", playerid);
return 1;
}
PHP код:
IPAddressQuery(playerid); public IPAddressQuery(playerid)
{
if (!cache_num_rows())
return print("Accounts with that IP Address were not found.");
new
rString[128], rName[32]
;
for(new i; i < cache_num_rows(); i++){
cache_get_value(i, "Name", rName);
format (rString, sizeof rString, "Found '%s' with the IP address specified.", rName);
SendClientMessage(playerid, -1, rString);
}
return 1;
}
We loop through the rows in the instance there are more than one account associated with the IP.