MySQL Error
#1

When logging in my server, my server crashes.

Here's the login script:

pawn Код:
stock MySQL_Login(playerid)
{
    GivePlayerMoney(playerid,16000);
    new query[300], pname[24], savingstring[20];
    GetPlayerName(playerid, pname, 24);
    format(query, sizeof(query), "SELECT * FROM PlayerData WHERE Name = '%s'", pname);
    mysql_query(query);
    mysql_store_result();
    while(mysql_fetch_field(query,"|"))
    {

        mysql_fetch_row(savingstring, "Score"); SetPlayerScore(playerid, strval(savingstring));
        mysql_fetch_row(savingstring, "PlayerLevel"); APlayerData[playerid][PlayerLevel] = strval(savingstring);
        mysql_fetch_row(savingstring, "OFWarns"); APlayerData[playerid][OFWarns] = strval(savingstring);

    }
    mysql_free_result();

    return 1;
}
I am using Strickenkids his mysql plugin.

Error:
Код:
[15:49:39] [MySQL] Error (0): Function: mysql_fetch_field could not find field name: "SELECT * FROM PlayerData WHERE Name = 'Entertainment'".
Anyone in the mood to help me out of this?

Thanks
Reply
#2

Can you show me the structure of PlayerData table?
Reply
#3



There you go. (if this is what you meant)

EDIT: I know I don't fetch everything yet, still testing some stuff out.
Reply
#4

Can you show me how are you making the connection to your database?
Reply
#5

pawn Код:
mysql = mysql_init(LOG_ALL);

    mysql_connect(SQL_HOST,SQL_USER,SQL_PASS,SQL_DB,mysql,1);
Do you need this....
Reply
#6

No I don't, I'm sorry, I got one thing missed from your code lawl.
Try to replace your while with this one:
PHP код:
while(mysql_retrieve_row()){ 
Reply
#7

I'm using strickenkids his mysql plugin, that function isn't in there.

C:\Users\Barbara\Desktop\SAMP Kevin\hoi\gamemodes\PPC_Trucking.pwn(470) : error 017: undefined symbol "mysql_retrieve_row"
Reply
#8

Sorry my bad, I've never worked with that plugin...
Reply
#9

pawn Код:
stock MySQL_Login(playerid)
{
    GivePlayerMoney(playerid,16000);
    new query[128], pname[24], savingstring[20];
    GetPlayerName(playerid, pname, 24);
    format(query, sizeof(query), "SELECT * FROM `PlayerData` WHERE `Name` = '%s'", pname);
    mysql_query(query);
    mysql_store_result();
    while(mysql_fetch_row(query,"|"))
    {

        mysql_fetch_field("Score", savingstring); SetPlayerScore(playerid, strval(savingstring));
        mysql_fetch_field("PlayerLevel", savingstring); APlayerData[playerid][PlayerLevel] = strval(savingstring);
        //mysql_fetch_field("OFWarns", savingstring); APlayerData[playerid][OFWarns] = strval(savingstring);

    }
    mysql_free_result();
    return 1;
}
I've commented out the OFWarns field fetching since I haven't seen it in your screen, if you're sure that field is there just uncomment the line.
Reply
#10

That makes my server crashing, I already tried that.

Mysql error log:

Код:
[Thu May 31 16:31:33 2012] -------------------------
[Thu May 31 16:31:34 2012] Function: mysql_init executed with result: "0".
[Thu May 31 16:31:34 2012] Connected (0) to 5436_transrp @ fr7.volt-host.com via TCP/IP.
[Thu May 31 16:31:34 2012] MySQL Server Version 5.1.61.
[Thu May 31 16:31:58 2012] Function: mysql_query executed: "SELECT Ip FROM `PlayerData` WHERE Name = 'Entertainment' LIMIT 1" with result: "0".
[Thu May 31 16:31:58 2012] Function: mysql_store_result executed with result: "1"
[Thu May 31 16:31:58 2012] Function: mysql_num_rows executed with result: "".
[Thu May 31 16:31:58 2012] Function: mysql_fetch_row executed with result: "1270".
[Thu May 31 16:31:58 2012] Function: mysql_free_result executed.
[Thu May 31 16:32:01 2012] Function: mysql_real_esacpe_string executed: "youmaynotseethispassword" with result: "youmaynotseethispassword".
[Thu May 31 16:32:01 2012] Function: mysql_query executed: "SELECT `Name` FROM PlayerData WHERE Name = 'Entertainment' AND Password = 'youmaynotseethispassword'" with result: "0".
[Thu May 31 16:32:01 2012] Function: mysql_store_result executed with result: "1"
[Thu May 31 16:32:01 2012] Function: mysql_num_rows executed with result: "".
[Thu May 31 16:32:01 2012] Function: mysql_query executed: "SELECT * FROM PlayerData WHERE Name = 'Entertainment'" with result: "0".
[Thu May 31 16:32:01 2012] Function: mysql_store_result executed with result: "1"
[Thu May 31 16:32:01 2012] Function: mysql_fetch_row executed with result: "Entertainment|youmaynotseethispassword|6|NULL|0|NULL|NULL|NULL|NULL|NULL|NULL|NULL|NULL|NULL|NULL|NULL|NULL|0|0|0|0|0|0|0|0|0|0|1270|0".
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)