new query[600],loadstr[20],pName[MPN];
GetPlayerName(playerid,pName,MPN);
format(query,sizeof(query),"SELECT * FROM accounts WHERE Name = '%s'",pName);
mysql_query(query);
mysql_store_result();
while(mysql_fetch_row_format(query,"|"))
{
//sscanf(query,"p<|>ds[24]s[129]",AccountInfo[playerid][Id],AccountInfo[playerid][Name],AccountInfo[playerid][Password]); <-- I decided to test it with sscanf and it worked properly.
mysql_fetch_field_row(loadstr,"ID"); AccountInfo[playerid][Id] = strval(loadstr);
//^ works properly aswell, I printed out the ID and it's correct.
//The last debug print shows here.
mysql_fetch_field_row(AccountInfo[playerid][Name],"Name"); //<-- Crashes here.
mysql_fetch_field_row(AccountInfo[playerid][Password],"Password");
}
mysql_free_result();
[16:53:19] >> mysql_query( Connection handle: 1 ) [16:53:19] CMySQLHandler::Query(SELECT * FROM accounts WHERE name = 'Alonso_Moreno') - Successfully executed. [16:53:19] >> mysql_store_result( Connection handle: 1 ) [16:53:19] CMySQLHandler::StoreResult() - Result was stored. [16:53:19] >> mysql_num_rows( Connection handle: 1 ) [16:53:19] CMySQLHandler::NumRows() - Returned 1 row(s) [16:53:22] >> mysql_query( Connection handle: 1 ) [16:53:22] CMySQLHandler::Query(SELECT * FROM accounts WHERE Name = 'Alonso_Moreno' AND Password = '000848C01650C0BC877F49A29F45A1AF342A7521E7EEE3B4960DF61AA5739085FD8CF38C22AA4F63E48E289134C822D521CBF9E5B75AD1D96C1C43F8B474CC24') - Successfully executed. [16:53:22] >> mysql_store_result( Connection handle: 1 ) [16:53:22] CMySQLHandler::StoreResult() - Result was stored. [16:53:22] >> mysql_num_rows( Connection handle: 1 ) [16:53:22] CMySQLHandler::NumRows() - Returned 1 row(s) [16:53:22] >> mysql_query( Connection handle: 1 ) [16:53:22] CMySQLHandler::Query(SELECT * FROM accounts WHERE Name = 'Alonso_Moreno') - Successfully executed. [16:53:22] >> mysql_store_result( Connection handle: 1 ) [16:53:22] CMySQLHandler::StoreResult() - Result was stored. [16:53:22] >> mysql_retrieve_row( Connection handle: 1 ) [16:53:22] >> mysql_fetch_field_row( Connection handle: 1 ) [16:53:22] CMySQLHandler::FetchField("ID") - 8 [16:53:22] >> mysql_fetch_field_row( Connection handle: 1 )
Well using sscanf is better because it's faster, it doesn't need any converting such as strval, floatstr and those stuff, also you should begin with the latest version, what's the point of learning the oldest version? well I suggest you learn ORM - Object-Relational Mapping.
Useful Links: https://sampforum.blast.hk/showthread.php?tid=461766 https://sampforum.blast.hk/showthread.php?tid=493138 https://sampwiki.blast.hk/wiki/MySQL/R33 |
NOTE: DON'T USE VERSION R7 OR ABOVE IF YOU HAVE NO IDEA WHAT THREADING MEANS OR HOW IT WORKS. YOU MIGHT HARM YOUR SERVER WHEN USING IT NOT PROPERLY. |