Problem with MySQL updating
#1

So i tried to make a little test script, to check out MySQL R38 plugin. Problem is with updating player data, when he disconnects. I have tried, to increase sizeof query, but nothing changed.

pawn Код:
mysql_format(mysql,query,sizeof(query),"UPDATE playerid SET pX='%f',pY='%f', pZ='%f' WHERE MysqlID=%d",x,y,z,alevel,sqlid);
mysql_tquery(mysql,query);
pawn Код:
[21:46:00] [DEBUG] mysql_format - connection: 1, len: 128, format: "UPDATE playerid SET pX='%f',pY='%f', pZ='%f' WHERE MysqlID=%d"
[21:46:00] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE playerid SET pX='867.628723',pY='-11.248103', pZ='63.1953", callback: "(null)", format: "(null)"
Reply
#2

Have you tried WHERE MysqlID='%d'
Reply
#3

Yes, it didn't change anything.
Reply
#4

1. You haven't added any specifier for variable 'alevel'.
2. Table doesn't exist?
3. Dead connection ?
4. What's the purpose of sqlid. If it is made to be some unique ID, why aren't you getting playerid instead of making it global.
5. What is that 'playerid' table name, is that even correct?

Try to debug some more. 'LOG_ALL' and 'LOG_HTML' for easy log in a proper HTML file.

pawn Код:
mysql_log(LOG_ALL, LOG_TYPE_HTML); // OnGameModeInit or OnFilterScriptInit
Reply
#5

Remove the single quotes from around the %f,

only use a single quote if the data being replaced is a string.

So if the data your replacing is using %s or %e then use single quote for everything else you don't need any single quotes
Reply
#6

First i didn't have these quotes around %f, but if it didn't worked, i changed it. Also i have mysql_log(log_all);
I tried to use mysql_query and it didn't work either.
pawn Код:
[21:46:00] [DEBUG] mysql_format - connection: 1, len: 128, format: "UPDATE playerid SET pX='%f',pY='%f', pZ='%f' WHERE MysqlID=%d"
[21:46:00] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE playerid SET pX='867.628723',pY='-11.248103', pZ='63.1953", callback: "(null)", format: "(null)"
[21:46:00] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[21:46:00] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 0.631 milliseconds
[21:46:01] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving
Reply
#7

Remove %f and try %s
Reply
#8

Quote:
Originally Posted by AA9
Посмотреть сообщение
First i didn't have these quotes around %f, but if it didn't worked, i changed it. Also i have mysql_log(log_all);
I tried to use mysql_query and it didn't work either.
pawn Код:
[21:46:00] [DEBUG] mysql_format - connection: 1, len: 128, format: "UPDATE playerid SET pX='%f',pY='%f', pZ='%f' WHERE MysqlID=%d"
[21:46:00] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE playerid SET pX='867.628723',pY='-11.248103', pZ='63.1953", callback: "(null)", format: "(null)"
[21:46:00] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[21:46:00] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 0.631 milliseconds
[21:46:01] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving
Nice to see you have skipped my post. Read it carefully, it has your solution.
Reply
#9

Quote:
Originally Posted by iZN
Посмотреть сообщение
1. You haven't added any specifier for variable 'alevel'.
2. Table doesn't exist?
3. Dead connection ?
4. What's the purpose of sqlid. If it is made to be some unique ID, why aren't you getting playerid instead of making it global.
5. What is that 'playerid' table name, is that even correct?

Try to debug some more. 'LOG_ALL' and 'LOG_HTML' for easy log in a proper HTML file.

pawn Код:
mysql_log(LOG_ALL, LOG_TYPE_HTML); // OnGameModeInit or OnFilterScriptInit
1. Here's version with mysql_query.
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    if(Logitud[playerid] == true)
    {
        new query[128];
        new Float:x;
        new Float:y;
        new Float:z;
        new alevel = pInfo[playerid][Admin];
        new sqlid = pInfo[playerid][MysqlID];
        GetPlayerPos(playerid,x,y,z);
        format(query,sizeof(query),"UPDATE playerid SET pX=%f,pY=%f, pZ=%f WHERE MysqlID=%d",x,y,z,sqlid);
        mysql_query(mysql,query);
        Logitud[playerid] = false;
    }
    return 1;
}
2. Table exists
3.No
4.When player register, then he's SQLID will be last AUTO_INCREMENT value.
5.Yes, table name is "playerid"
Reply
#10

All worked fine, when i didn't save player cordinates. When i added cordinate saving back, it again didn't work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)