field_not_found but they exists!
#1

Ok ignore my last topic. I have a problem with my MySql login system, this is what is printed in mysq_log.txt file:

Quote:

[16:15:36] [DEBUG] Calling callback "CheckAcc"..
[16:15:36] [DEBUG] cache_get_row_count - connection: 1
[16:15:36] [DEBUG] cache_get_field_content - row: 0, field_name: "IP", connection: 1, max_len: 129
[16:15:36] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "IP", data: "HIDDEN IP"
[16:15:36] [DEBUG] mysql_tquery - connection: 1, query: "SELECT RegisterDate, Admin, VIP, Money, Score, Deaths, MissionsP", callback: "(null)", format: "(null)"
[16:15:36] [DEBUG] CMySQLQuery::CMySQLQuery() - constructor called
[16:15:36] [DEBUG] mysql_tquery - scheduling query "SELECT RegisterDate, Admin, VIP, Money, Score, Deaths, MissionsPlayed, VipTime, Warns, Cookies, Jailed, Muted, Duty, Nopm FROM players WHERE Username = 'Face9000'"..
[16:15:36] [DEBUG] cache_get_row_count - connection: 1
[16:15:36] [DEBUG] cache_get_field_count - connection: 1
[16:15:36] [DEBUG] cache_get_row - row: 0, field_idx: 0, connection: 1, max_len: 512
[16:15:36] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '0', data: "FD9D94340DBD72C11B37EBB0D2A19B4D05E00FD78E4E2CE89 23B9EA3A54E900DF181CFB112A8A73228D1F3551680E2AD970 1A4FCFB248FA7FA77B95180628BB2"
[16:15:36] [DEBUG] cache_get_row - row: 0, field_idx: 1, connection: 1, max_len: 512
[16:15:36] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '1', data: "HIDDEN IP"
[16:15:36] [DEBUG] cache_get_field_content - row: 0, field_name: "RegisterDate", connection: 1, max_len: 20
[16:15:36] [WARNING] CMySQLResult::GetRowDataByName - field not found ("RegisterDate")
[16:15:36] [DEBUG] cache_get_field_content - row: 0, field_name: "Admin", connection: 1, max_len: 20
[16:15:36] [WARNING] CMySQLResult::GetRowDataByName - field not found ("Admin")
[16:15:36] [DEBUG] cache_get_field_content - row: 0, field_name: "VIP", connection: 1, max_len: 20
[16:15:36] [WARNING] CMySQLResult::GetRowDataByName - field not found ("VIP")
[16:15:36] [DEBUG] cache_get_field_content - row: 0, field_name: "Cash", connection: 1, max_len: 20
[16:15:36] [WARNING] CMySQLResult::GetRowDataByName - field not found ("Cash")
[16:15:36] [DEBUG] cache_get_field_content - row: 0, field_name: "Score", connection: 1, max_len: 20
[16:15:36] [WARNING] CMySQLResult::GetRowDataByName - field not found ("Score")
[16:15:36] [DEBUG] cache_get_field_content - row: 0, field_name: "Deaths", connection: 1, max_len: 20
[16:15:36] [WARNING] CMySQLResult::GetRowDataByName - field not found ("Deaths")
[16:15:36] [DEBUG] cache_get_field_content - row: 0, field_name: "MissionsPlayed", connection: 1, max_len: 20
[16:15:36] [WARNING] CMySQLResult::GetRowDataByName - field not found ("MissionsPlayed")
[16:15:36] [DEBUG] cache_get_field_content - row: 0, field_name: "VipTime", connection: 1, max_len: 20
[16:15:36] [WARNING] CMySQLResult::GetRowDataByName - field not found ("VipTime")
[16:15:36] [DEBUG] cache_get_field_content - row: 0, field_name: "Warns", connection: 1, max_len: 20
[16:15:36] [WARNING] CMySQLResult::GetRowDataByName - field not found ("Warns")
[16:15:36] [DEBUG] cache_get_field_content - row: 0, field_name: "Cookies", connection: 1, max_len: 20
[16:15:36] [WARNING] CMySQLResult::GetRowDataByName - field not found ("Cookies")
[16:15:36] [DEBUG] cache_get_field_content - row: 0, field_name: "Jailed", connection: 1, max_len: 20
[16:15:36] [WARNING] CMySQLResult::GetRowDataByName - field not found ("Jailed")
[16:15:36] [DEBUG] cache_get_field_content - row: 0, field_name: "Muted", connection: 1, max_len: 20
[16:15:36] [WARNING] CMySQLResult::GetRowDataByName - field not found ("Muted")
[16:15:36] [DEBUG] cache_get_field_content - row: 0, field_name: "Duty", connection: 1, max_len: 20
[16:15:36] [WARNING] CMySQLResult::GetRowDataByName - field not found ("Duty")
[16:15:36] [DEBUG] cache_get_field_content - row: 0, field_name: "Nopm", connection: 1, max_len: 20
[16:15:36] [WARNING] CMySQLResult::GetRowDataByName - field not found ("Nopm")
[16:15:36] [DEBUG] cache_get_row_count - connection: 1
[16:15:36] [DEBUG] cache_get_field_count - connection: 1
[16:15:36] [DEBUG] cache_get_row - row: 1, field_idx: 0, connection: 1, max_len: 512
[16:15:36] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('0')
[16:15:36] [DEBUG] cache_get_row - row: 1, field_idx: 1, connection: 1, max_len: 512
[16:15:36] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('1')

But the fields are created in the "players" table:

http://s10.postimg.org/dk0nybmex/Immagine.jpg

This is the stock which handles the login:

Код:
stock MySQL_Login(playerid)
{
    new query2[650], pname[24], savingstring[20];
    WP_Hash(query2, 650, savingstring);
    GetPlayerName(playerid, pname, 24);
    format(query2, sizeof(query2), "SELECT RegisterDate, Admin, VIP, Money, Score, Deaths, MissionsPlayed, VipTime, Warns, Cookies, Jailed, Muted, Duty, Nopm FROM players WHERE Username = '%s'", pname);
    mysql_function_query(mConnectionHandle, query2, false, "", "");
    mysql_store_result();
    while(mysql_fetch_row_format(query2,"|"))
    {
    	mysql_fetch_field_row(savingstring, "RegisterDate"); PlayerInfo[playerid][RegisterDate] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Admin"); PlayerInfo[playerid][Admin] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "VIP"); PlayerInfo[playerid][VIP] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Cash"); SetPlayerCash(playerid, strval(savingstring));
        mysql_fetch_field_row(savingstring, "Score"); SetPlayerScore(playerid, strval(savingstring));
        mysql_fetch_field_row(savingstring, "Deaths"); PlayerInfo[playerid][Deaths] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "MissionsPlayed"); PlayerInfo[playerid][MissionsPlayed] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "VipTime"); PlayerInfo[playerid][VipTime] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Warns"); PlayerInfo[playerid][Warns] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Cookies"); PlayerInfo[playerid][Cookies] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Jailed"); PlayerInfo[playerid][Jailed] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Muted"); PlayerInfo[playerid][Muted] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Duty"); PlayerInfo[playerid][Duty] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Nopm"); PlayerInfo[playerid][Nopm] = strval(savingstring);
    }
    mysql_free_result();
    JustLogged[playerid] = 1;
    Logged[playerid] = 1;
	SendClientMessage(playerid,red,"------------------------------------------------------");
	new	playername3[MAX_PLAYER_NAME];
	GetPlayerName(playerid, playername3, sizeof(playername3));
	new string[128];
    format(string,sizeof(string),"* System: Welcome back {F70505}%s (%d) {FFFFFF} - Your stats have been restored.",playername3,playerid);
	SCM(playerid,-1,string);
	SendClientMessage(playerid,red,"------------------------------------------------------");
	CheckVipTime(playerid);
    return 1;
}
If you need more code feel free to ask.
Reply
#2

Show a screenshot or the code of your database structure.
Reply
#3

Reply
#4

Sorry for asking this, but are you sure that you have connected to the right database? (you might have more than one database)

- also after looking at the int(20) you shouldn't set it to 20 length, you should set it to 11 for example (this might be unrelated, but an advice doesn't hurt right?)
Reply
#5

I'm sure that i connect to the correct database because the player account is created (phpmyadmin and mysql log confirms it)..
Reply
#6

On the last topic someone explained how that works
You can't do that after calling the query cuz it doesn't work like that, it used to work like it in R6, and you are following that old tutorial, try fetching those fields under your specified callback and they will exist, request them on random places and they won't,
As I said last time, please try to edit your script to R33 methods and your problem will be solved
( by R33 I mean 1- Requesting data from mysql in callbacks, 2- updated functions, afaik there is no mysql fetch field row anymore. )
Reply
#7

Can you make me an example with the current code?
Reply
#8

Sure

PHP код:
    mysql_format(mysqlquerysizeof(query),"SELECT * FROM `TableX`");
    
mysql_tquery(mysqlquery"OnSomethingLoad"); 
and then you make a callback (a public function with forward)
PHP код:
public OnSomethingLoad()
{
     new 
cache_get_row_count();
    for(new 
i=0i++)
    {
        
cache_get_field_content(i"Name"Sth[i][Name], mysql30);
        
Sth[i][Type] = cache_get_field_content_int(i"Type");
        
Sth[i][X] = cache_get_field_content_float(i"X");
    } 
This is an example of how, where and what commands to use to get information from the mysql, you need to change all your code to match this format, cuz when you make a t(hreaded)query you receive results in a callback, not right after it ( under your code)
Reply
#9

I got already what you're saying:

This is OnPlayerConnect:

Код:
	new query[85], pname[24];
    GetPlayerName(playerid, pname, 24);
    mysql_format(mConnectionHandle, query, sizeof(query), "SELECT Password, IP FROM `players` WHERE Username = '%e' LIMIT 1", pname);
    mysql_tquery(mConnectionHandle, query, "CheckAcc", "d", playerid);
See? I call the CheckAcc callback.

Код:
public CheckAcc(playerid)
{
    if(!IsPlayerConnected(playerid))return 1;
    if(!cache_get_row_count(mConnectionHandle))ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""White"Please register",""White"Welcome to "Red""SERVER_NAME""White"!\n"White"In order to start playing, you have to register!\n\n"White"Please insert a password below:", "Register", "Cancel");
    else {
        IsRegistered[playerid] = 1;
        new ppip[16], temp[129];
        GetPlayerIp(playerid, ppip, 16);
        cache_get_field_content(0, "IP", temp);
        if(strlen(temp) > 2 && !strcmp(ppip , temp))return MySQL_Login(playerid);
        cache_get_field_content(0, "Password", temp), format(passkey[playerid], 129, "%s", temp);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""White"Please log-in", ""White"Welcome back to "Red""SERVER_NAME""White"!\n"White"In order to start playing, you have to log-in!\n\n"White"Please insert "Red"your"White" password below:", "Login", "Cancel");
    }
    return 1;
}
Reply
#10

Sure, your account check works, now you need to do the same with your MYSQL_Login, I would suggest removing that function as calling a function just to call a query is kinda useless, instead everytime you wanna login you can query this, and load all your player info on AccountLogin callback
PHP код:
    mysql_format(mConnectionHandlequerysizeof(query), "SELECT * FROM `players` WHERE Username = '%e' LIMIT 1"pname);
    
mysql_tquery(mConnectionHandlequery"AccountLogin""d"playerid); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)