17.09.2013, 19:13
I have a table named pAccounts, and my first row is playerID. The second row is playerName. I do like this:
The result is: -1 ( in my table, playerID is 5 ).
I can confirm to you that MyName it's already on my table, and the condition if(mysql_num_rows()) is evaluated as true.
pawn Код:
stock RetrieveID(const name[])
{
new str[128];
format(str, 128, "SELECT `playerID` FROM `pAccounts` WHERE `playerName` = '%s'", name);
mysql_query(str);
mysql_store_result(); // Store the result
new resultID = -1;
if(mysql_num_rows())
{
resultID = mysql_fetch_int();
}
mysql_free_result(); // Free the result
return resultID;
}
// Somewhere ( of course, the database connection is established )
printf("%d", RetrieveID("MyName"));
I can confirm to you that MyName it's already on my table, and the condition if(mysql_num_rows()) is evaluated as true.