MySQL problem
#1

Ok so here is my problem... I am trying to make a MySQL system but I am a newbie at MySQL and so I don't know how to get around that well... At first the script worked fine, it was saving accounts in the database etc. But i added 3 new parameters (organisation, leader, and rank) and then it just wouldn't save anymore ... I think the problem is in the query's (from what i know they are in charge of writing/reading the database...).

At first I thought that the string size wasn't big enough (it was 200) so I made it 1600 just to check and still nothing ... here are all the querys I have in the gamemode, and i would be greatfull if someone could find the problem and tell me how to solve it...

This is on OnGameModeInit (checks if there is a table present and if not creates it (thats what i read in the tut )
Код:
mysql_query("CREATE TABLE IF NOT EXISTS playerdata(user VARCHAR(24), password VARCHAR(41), level INT(20), money INT(20), admin INT(5), skin INT(3), org INT(2), lider INT(2), rank INT(2), IP VARCHAR(16) )");
I believe that this one is for checking the last IP (for the auto-login)
Код:
new query[1600], pname[24];
    GetPlayerName(playerid, pname, 24);
    format(query, sizeof(query), "SELECT IP FROM `playerdata` WHERE user = '%s' LIMIT 1", pname); 
    mysql_query(query);
This one is for updating the database (i guess)
Код:
new level = GetPlayerScore(playerid);
        new money = GetPVarInt(playerid, "Novac");
        new admin = GetPVarInt(playerid, "Admin");
        new skin = GetPVarInt(playerid, "Skin");
        new org = GetPVarInt(playerid, "Org");
        new lider = GetPVarInt(playerid, "Lider");
        new rank = GetPVarInt(playerid, "Rank");
        new query[1600], pname[24];
        GetPlayerName(playerid, pname, 24);
        format(query, sizeof(query), "UPDATE playerdata SET level=%d, money=%d, admin=%d, skin=%d, org=%d, lider=%d, rank=%d WHERE user='%s'", level, money, admin, skin, org, lider, rank, pname);
        mysql_query(query);
This one is in the DialogResponse for the login dialog
Код:
format(query, sizeof(query), "SELECT `user` FROM playerdata WHERE user = '%s' AND password = SHA1('%s')", pname, escapepass);
            mysql_query(query);
This one is in the register stock
Код:
format(query, sizeof(query), "INSERT INTO playerdata (user, password, level, money, admin, skin, org, lider, rank, IP) VALUES('%s', SHA1('%s'), 1, 5000, 0, 1, 0, 0, 0, '%s')", pname, passwordstring, IP);
    mysql_query(query);
And this one is in the login stock
Код:
format(query, sizeof(query), "SELECT * FROM playerdata WHERE user = '%s'", pname);
    mysql_query(query);
thats all the querys in the mod...

Thanks in advance
Reply
#2

BUMP anyone?
Reply
#3

Why you dont show as debug (mysql log) that you can find if you have any error in your querys
Reply
#4

And where do i find it?

EDIT: Thanks for the debug tip i found the error using it and fixed it... by mistake I changed a columbs name in the database...
Reply
#5

That's a bad idea.

pawn Код:
new level = GetPlayerScore(playerid);
        new money = GetPVarInt(playerid, "Novac");
        new admin = GetPVarInt(playerid, "Admin");
        new skin = GetPVarInt(playerid, "Skin");
        new org = GetPVarInt(playerid, "Org");
        new lider = GetPVarInt(playerid, "Lider");
        new rank = GetPVarInt(playerid, "Rank");
You should have an enum for player variables. And as doreto said, you could show us the mysql_log file, so that the problem could be solved easier.
Reply
#6

Quote:
Originally Posted by Tika Spic
Посмотреть сообщение
And where do i find it?

EDIT: Thanks for the debug tip i found the error using it and fixed it... by mistake I changed a columbs name in the database...
PHP код:
public OnGameModeInit()
{
    
mysql_debug(1);

check if you have it if not add it make the things that make you problem and show as the debug loc
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)