Problem with MySQL Bank System
#1

Hey,

I've been trying to script the base of a MySQL Bank System, and it doesn't seem to save the data.

I have 3 different functions,

pawn Код:
LoadBank(playerid)
{
    new
        name[ MAX_PLAYER_NAME ],
        query[ 300 ];
       
    GetPlayerName(playerid, name, sizeof(name));
    format(query, sizeof(query), "SELECT * FROM Bank WHERE Name='%s'", name);
    mysql_query(query);

    new String[ 40 ];
    mysql_store_result();
    while(mysql_fetch_row_format(query,"|"))
    {
        mysql_fetch_field_row(bInfo[playerid][bMoney],"bMoney");
        mysql_fetch_field_row(String,"AccID"); bInfo[playerid][AccID] = strval(String);
    }
    mysql_free_result();
}

SaveBank(playerid)
{
    new
        name[ MAX_PLAYER_NAME ],
        str[ 300 ];
       
    GetPlayerName(playerid, name, sizeof(name));
    format(str,sizeof(str),"UPDATE Bank SET bMoney=%d WHERE Name='%s'", bInfo[playerid][bMoney], name);
    mysql_query(str);
}

CreateBank(playerid)
{
    new
        name[ MAX_PLAYER_NAME ],
        query[ 300 ];

    GetPlayerName(playerid, name, sizeof(name));
    format(query, sizeof(query), "INSERT INTO Bank (Name, Money) VALUES('%s', 0)", name);
    mysql_query(query);
    mysql_free_result();
}
LoadBank, SaveBank, CreateBank.

So I have placed LoadBank under my MySQL login function, SaveBank on disconnect and CreateBank on mmy MySQL register function.

It doesn't seem to work. A new player has registered and their name wasn't saved to the table Banks

How am I able to fix this problem?

Thanks,

FunnyBear
Reply
#2

Bank and Banks are two different tables make sure its the right one caz in description u writed that table name is Banks where as in code it is Bank
Reply
#3

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
Bank and Banks are two different tables make sure its the right one caz in description u writed that table name is Banks where as in code it is Bank
Yeah, sorry it was a typo. I meant to write Bank. The table name is the exact name in the script
Reply
#4

put this in your OnGameModeInit -
mysql_log(1);
Now run the system then show us the mysql log file created in server directory
Reply
#5

Are you sure not using " ` " around 'Bank' will work? I never worked on MySQL queries without ` symbols around the name of the variable. Try using ` around it, like:
pawn Код:
"UPDATE `Bank` SET `bMoney`='%d' WHERE `Name`='%s'"
Reply
#6

Quote:
Originally Posted by LivingLikeYouDo
Посмотреть сообщение
Are you sure not using " ` " around 'Bank' will work?
Yes.
Reply
#7

When I looked at the Avatar, the first thought that came to me was 'It's Vince? And He's asking something? Darn it.' XD
Reply
#8

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
put this in your OnGameModeInit -
mysql_log(1);
Now run the system then show us the mysql log file created in server directory
Thanks, I had commented mysql_debug before, and when I had removed the comment, I figured out the problem. On my CreateBank, I had Money, instead of bMoney. Silly me

Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)