mysql_fetch_field_row
#1

Hey,

Iam bussy with a gamemode (mysql)
but when somebody login, the server crash.
Log:
Quote:

The server has been crashed by native mysql_fetch_field_row at address 41ac in script gamemodes\RRP.amx.

No mysql log,
its from crash detector plugin
Code:
pawn Code:
stock MySQL_Login(playerid)
{
    new query[300], pname[24], savingstring[20];
    GetPlayerName(playerid, pname, 24);
    format(query, sizeof(query), "SELECT * FROM users WHERE name = '%s' LIMIT 1", pname);
    mysql_query(query);
    mysql_store_result();
    while(mysql_fetch_row_format(query,"|"))
    {
        mysql_fetch_field_row(savingstring, "level"); SetPlayerScore(playerid, strval(savingstring));
        ResetPlayerMoney(playerid);
        mysql_fetch_field_row(savingstring, "money"); GivePlayerMoney(playerid, strval(savingstring));
        mysql_fetch_field_row(savingstring, "Adminlevel"); Playerdata[playerid][Adminlevel] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "bank"); Playerdata[playerid][Bank] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "exp"); Playerdata[playerid][Exp] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "tut"); Playerdata[playerid][Bank] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "xpos"); Playerdata[playerid][Xpos] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "ypos"); Playerdata[playerid][Ypos] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "zpos"); Playerdata[playerid][Zpos] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "apos"); Playerdata[playerid][Apos] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "tut"); Playerdata[playerid][Tut] = strval(savingstring);
    }
    mysql_free_result();
    SendClientMessage(playerid, -1, "You have been logged in.");
    SetSpawnInfo(playerid, -1, Playerdata[playerid][Skin], Playerdata[playerid][Xpos], Playerdata[playerid][Ypos],                  Playerdata[playerid][Zpos], Playerdata[playerid][Apos], -1, -1, -1, -1, -1, -1);
    SpawnPlayer(playerid);
    return 1;
}
its when a player login, they can register normal.
Structuur:
Code:
CREATE TABLE IF NOT EXISTS `users` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `name` varchar(225) NOT NULL,
  `password` text NOT NULL,
  `skin` int(5) NOT NULL DEFAULT '101',
  `Adminlevel` enum('0','1','2','3','4','5','6','7','1337','1338') NOT NULL DEFAULT '0',
  `ip` varchar(20) NOT NULL,
  `money` int(225) NOT NULL DEFAULT '5000',
  `bank` int(225) NOT NULL DEFAULT '2500',
  `level` int(10) NOT NULL DEFAULT '1',
  `exp` int(10) NOT NULL DEFAULT '0',
  `xpos` float NOT NULL DEFAULT '1685.84',
  `ypos` float NOT NULL DEFAULT '-2333.34',
  `zpos` float NOT NULL DEFAULT '-2.6797',
  `apos` float NOT NULL DEFAULT '1.4551',
  `tut` enum('0','1') NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
thanks!
Reply
#2

EDIT: nevermind.. again. I'm being dumb today.
Reply
#3

You mean you shouldn't SELECT * FROM before? Can't imagine that, but I think I understand you wrong.
Reply
#4

i got an error in one of this lines:
pawn Code:
mysql_fetch_field_row(savingstring, "level"); SetPlayerScore(playerid, strval(savingstring));
        mysql_fetch_field_row(savingstring, "money"); GivePlayerMoney(playerid, strval(savingstring));
        mysql_fetch_field_row(savingstring, "Adminlevel"); Playerdata[playerid][Adminlevel] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "bank"); Playerdata[playerid][Bank] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "exp"); Playerdata[playerid][Exp] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "tut"); Playerdata[playerid][Bank] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "xpos"); Playerdata[playerid][Xpos] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "ypos"); Playerdata[playerid][Ypos] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "zpos"); Playerdata[playerid][Zpos] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "apos"); Playerdata[playerid][Apos] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "tut"); Playerdata[playerid][Tut] = strval(savingstring);
What do i wrong there?

@Macluawn Loop removed ;p, it was from a tutorial :$
Reply
#5

Read in wikipedia the result of those functions. It's some bad tutorial you readed.
try this:
pawn Code:
MySQL_Login(playerid)
{
    new query[67], pname[24], savingstring[64];
    GetPlayerName(playerid, pname, 24);
    format(query, sizeof(query), "SELECT * FROM users WHERE name = '%s' LIMIT 1", pname);
    mysql_query(query);
    mysql_store_result();
    if(mysql_fetch_row_format(savingstring,"|"))
    {
        mysql_fetch_field_row(savingstring, "level"); SetPlayerScore(playerid, strval(savingstring));
        ResetPlayerMoney(playerid);
        mysql_fetch_field_row(savingstring, "money"); GivePlayerMoney(playerid, strval(savingstring));
        mysql_fetch_field_row(savingstring, "Adminlevel"); Playerdata[playerid][Adminlevel] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "bank"); Playerdata[playerid][Bank] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "exp"); Playerdata[playerid][Exp] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "tut"); Playerdata[playerid][Bank] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "xpos"); Playerdata[playerid][Xpos] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "ypos"); Playerdata[playerid][Ypos] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "zpos"); Playerdata[playerid][Zpos] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "apos"); Playerdata[playerid][Apos] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "tut"); Playerdata[playerid][Tut] = strval(savingstring);
    }
    mysql_free_result();
    SendClientMessage(playerid, -1, "You have been logged in.");
    SetSpawnInfo(playerid, -1, Playerdata[playerid][Skin], Playerdata[playerid][Xpos], Playerdata[playerid][Ypos],                  Playerdata[playerid][Zpos], Playerdata[playerid][Apos], -1, -1, -1, -1, -1, -1);
    SpawnPlayer(playerid);
    return 1;
}
Reply
#6

Same error ;l
Reply
#7

I have this now:
pawn Code:
MySQL_Login(playerid)
{
    new query[67], pname[24], savingstring[250];
    GetPlayerName(playerid, pname, 24);
    format(query, sizeof(query), "SELECT level, money, Adminlevel, bank, exp, xpos, ypos, zpos, apos, tut FROM users WHERE name = '%s' LIMIT 1", pname);
    mysql_query(query);
    mysql_store_result();
    if(mysql_fetch_row_format(savingstring))
    {
        sscanf(savingstring,"p<|>iiiiiffffi", Playerdata[playerid][Level], Playerdata[playerid][Money], Playerdata[playerid][Adminlevel], Playerdata[playerid][Bank], Playerdata[playerid][Exp], Playerdata[playerid][Xpos], Playerdata[playerid][Ypos], Playerdata[playerid][Zpos], Playerdata[playerid][Apos], Playerdata[playerid][Tut]);
    }
    mysql_free_result();
    SendClientMessage(playerid, -1, "You have been logged in.");
    SetSpawnInfo(playerid, -1, Playerdata[playerid][Skin], Playerdata[playerid][Xpos], Playerdata[playerid][Ypos], Playerdata[playerid][Zpos], Playerdata[playerid][Apos], -1, -1, -1, -1, -1, -1);
    SpawnPlayer(playerid);
    return 1;
}
But dont work.
And when i type /stats it gives:

______________|Stats|______________
Level: 0 - Exp: 0 - Skin: 1685024101
Money: 0.000000 - Bank: 0.000000 - Tutorial: 0

Script:
pawn Code:
CMD:stats(playerid, params[])
{
    SendClientMessage(playerid, COLOR_YELLOW, "______________|Stats|______________");
    format(string, sizeof(string), "Level: %i - Exp: %i - Skin: %i", GetPlayerScore(playerid), Playerdata[playerid][Exp], GetPlayerSkin(playerid));
    SendClientMessage(playerid, COLOR_YELLOW, string);
    format(string, sizeof(string), "Money: %f - Bank: %f - Tutorial: %i", GetPlayerMoney(playerid), Playerdata[playerid][Bank], Playerdata[playerid][Tut]);
    SendClientMessage(playerid, COLOR_YELLOW, string);
    return 1;
}
and i spawn on a freaky location. (Bluebarry)

Thanks...!
Reply
#8

Sorry for dubbel,dubbel post, but i now whats wrong, but how can i fix it?
Query:
Quote:

SELECT skin, Adminlevel, money, bank, level, exp, xpos, ypos, zpos, apos, tut FROM users WHERE name = '%s' LIMIT 1

(%s = the name of the player.)
Error:
Quote:

[20:17:48] CMySQLHandler::Query(SELECT skin, adminlevel, money, bank, level, exp, xpos, ypos, zpos) - An error has occured. (Error ID: 1054, Unknown column 'skin' in 'field list')

Database:
Quote:

CREATE TABLE IF NOT EXISTS `users` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`name` varchar(225) NOT NULL,
`password` text NOT NULL,
`skin` int(5) NOT NULL DEFAULT '101',
`adminlevel` enum('0','1','2','3','4','5','6','7','1337','1338' ) NOT NULL DEFAULT '0',
`ip` varchar(20) NOT NULL,
`money` int(225) NOT NULL DEFAULT '5000',
`bank` int(225) NOT NULL DEFAULT '2500',
`level` int(10) NOT NULL DEFAULT '1',
`exp` int(10) NOT NULL DEFAULT '0',
`xpos` float NOT NULL DEFAULT '1685.84',
`ypos` float NOT NULL DEFAULT '-2333.34',
`zpos` float NOT NULL DEFAULT '-2.6797',
`apos` float NOT NULL DEFAULT '1.4551',
`tut` enum('0','1') NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)