stock LoginPlayer(playerid, password[]) { mysql_format(1, query, sizeof(query), "SELECT * FROM master_data WHERE Username = '%e' AND Pass = '%e'", Username(playerid), password); mysql_query(1, query); cache_get_data(rows, fields); printf("There are currently %i rows and %i fields visable in the master_data db", rows, fields); if(cache_get_row_count() > 0) { //format(query, sizeof(query), "UPDATE master_data SET LastIP = '%s' WHERE Username = '%s'", PlayerIP(playerid), Username(playerid)); //mysql_query(query); cache_get_row(rows, 4, query); if(strfind(query, "")) return query = "Create Character"; MasterData[playerid][Char0] = query; print("Char0 set"); cache_get_row(rows, 5, query); if(strfind(query, "")) return query = "Create Character"; MasterData[playerid][Char1] = query; print("Char1 set"); cache_get_row(rows, 6, query); if(strfind(query, "")) return query = "Create Character"; MasterData[playerid][Char2] = query; print("Char2 set"); //format(msg, sizeof(msg), "Welcome back %s.\nYour stats have been loaded succesfully.\nThe last login for this account was from IP: %s", PlayerName(playerid), Player_Data[playerid][Last_IP]); format(str, sizeof(str), "%s\n%s\n%s\n \nAccount Settings", MasterData[playerid][Char0], MasterData[playerid][Char1], MasterData[playerid][Char2]); ShowPlayerDialog(playerid, DIALOG_CHARSELECT, DIALOG_STYLE_LIST, "Duck's Roleplay - Account", str, "Select", "Quit"); print("Dialog should be shown here"); } else { ShowPlayerDialog(playerid, DIALOG_RETRY, DIALOG_STYLE_PASSWORD, "Duck's Roleplay - Login", "Incorrect password!\nPlease enter your account password below:", "Login", "Quit"); } return 1; }
[14:33:26] [DEBUG] mysql_connect - host: "---.-.-.-", user: "---", database: "---", password: "*---", port: ----, autoreconnect: true, pool_size: 2 [14:33:26] [DEBUG] CMySQLHandle::Create - creating new connection.. [14:33:26] [DEBUG] CMySQLHandle::CMySQLHandle - constructor called [14:33:26] [DEBUG] CMySQLHandle::Create - connection created (id: 1) [14:33:26] [DEBUG] CMySQLConnection::Connect - establishing connection to database... [14:33:26] [DEBUG] CMySQLConnection::Connect - connection was successful [14:33:26] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [14:33:26] [DEBUG] mysql_errno - connection: 1 [14:33:26] [DEBUG] CMySQLConnection::Connect - establishing connection to database... [14:33:26] [DEBUG] CMySQLConnection::Connect - establishing connection to database... [14:33:26] [DEBUG] CMySQLConnection::Connect - connection was successful [14:33:26] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [14:33:26] [DEBUG] CMySQLConnection::Connect - connection was successful [14:33:26] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [14:33:26] [DEBUG] CMySQLConnection::Connect - connection was successful [14:33:26] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [14:34:03] [DEBUG] mysql_format - connection: 1, len: 128, format: "SELECT Count(ID) FROM master_data WHERE Username = '%e'" [14:34:03] [DEBUG] mysql_query - connection: 1, query: "SELECT Count(ID) FROM master_data WHERE Username = 'Duck'", use_cache: true [14:34:03] [DEBUG] CMySQLQuery::Execute - starting query execution [14:34:03] [DEBUG] CMySQLQuery::Execute - query was successfully executed within 74.45 milliseconds [14:34:03] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [14:34:03] [DEBUG] CMySQLHandle::SaveActiveResult - cache saved (id: 1) [14:34:03] [DEBUG] cache_get_row_count - connection: 1 [14:34:10] [DEBUG] mysql_format - connection: 1, len: 128, format: "SELECT * FROM master_data WHERE Username = '%e' AND Pass = '%e'" [14:34:10] [DEBUG] mysql_query - connection: 1, query: "SELECT * FROM master_data WHERE Username = 'Duck' AND Pass = 'pa", use_cache: true [14:34:10] [DEBUG] CMySQLQuery::Execute - starting query execution [14:34:10] [DEBUG] CMySQLQuery::Execute - query was successfully executed within 1.49 milliseconds [14:34:10] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [14:34:10] [DEBUG] CMySQLHandle::SaveActiveResult - cache saved (id: 2) [14:34:10] [DEBUG] cache_get_data - connection: 1 [14:34:10] [DEBUG] cache_get_row_count - connection: 1 [14:34:10] [DEBUG] cache_get_row - row: 1, field_idx: 4, connection: 1, max_len: 128 [14:34:10] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('4')
Look this tutorial mate,it helped me to understand alot things.
https://sampforum.blast.hk/showthread.php?tid=485633 |
Originally Posted by MySQL log
[14:34:10] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('4')
|
Your log pretty much tells you what the problem is: you're trying to retrieve data from a field/row that is non-existent.
And you do realise that you're not making use of any threaded queries in that snippet of code, right? I believe you either haven't read the correct tutorials or you haven't read enough of them yet. Give these tutorials a look: https://sampforum.blast.hk/showthread.php?tid=570635 https://sampforum.blast.hk/showthread.php?tid=485633 (More detailed: https://sampforum.blast.hk/showthread.php?tid=574714) |
I know it cannot find the row/field however they're there and they are filled, so I can't see what the problem is..
and yes.. i know |
Update your code with threaded queries, with help of the given tutorials in my previous reply and you should be able to get it right or are you waiting for me to give you the correct code with you only having to copy-paste it?
|
No, absolutely not.. how will I learn by doing that? I am trying to figure out what is wrong with this code because I am stuck and I have been trying to figure that out for a while now.. I will read the topics you suggested however I already have a general understanding about threading, this is why I am making the system; to learn more about threading and improve my coding abilities.
|
//Something here to get the rows id and put it into a variable //then.. cache_get_row(rowID, 4, query);
mysql_format(1, query, sizeof(query), "SELECT ID FROM master_data WHERE Username = '%e' AND Pass = '%e'", Username(playerid), password); new rowID = mysql_query(1, query);