Mysql not saving
#1

Hello guys , My mysql system don't save my admin level and the onther codes


PHP код:
stock MySQL_Register(playeridpasswordstring[])
{
    new 
query1[350], pname[24];
    new 
Bannedby[20];
    
format(Bannedby20"Not Banned");
    
GetPlayerName(playeridpname24);
    
format(query1sizeof(query1), "INSERT INTO playerdata (user, password, score,cookies, money, level, vip, kma, rank, kills, deaths, muted, jailed, frozen, mutedtimes, jailedtimes, frozentimes, logins, posx, posy, posz, posa, IP) VALUES('%s', SHA1('%s'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '%s')"pnamepasswordstringGetIP(playerid));
    
mysql_query(query1);
    
SendClientMessage(playerid,COLOR_PINK,"You have successfully registered on the server! Enjoy!");
    
GameTextForPlayer(playerid,"~G~You have registered successfully!",5000,4);
    
Logged[playerid] = 1;
mysql_query("SELECT * FROM playerdata");
mysql_store_result();
new 
rows mysql_num_rows();
mysql_free_result();
    new 
st[128];
    
format(st,128,"%s has registered at XtremeX, Total registered players %d",GetName(playerid),rows);
    
SendClientMessageToAll(COLOR_LIGHTBLUE,st);
    return 
1;
}
stock MySQL_Login(playerid)
{
    new 
query2[300], pname[24], savingstring[20];
    
GetPlayerName(playeridpname24);
    
format(query2sizeof(query2), "SELECT score,cookies, money, level, vip, kma, rank, kills, deaths, muted, jailed, frozen, mutedtimes, jailedtimes, frozentimes, logins, posx, posy, posz, posa FROM playerdata WHERE user = '%s'"pname);
    
mysql_query(query2);
    
mysql_store_result();
    while(
mysql_fetch_row_format(query2,"|"))
    {
        
mysql_fetch_field_row(savingstring"score"); SetPlayerScore(playeridstrval(savingstring));
        
mysql_fetch_field_row(savingstring"money"); MoneyGiven[playerid] = strval(savingstring);
        
mysql_fetch_field_row(savingstring"level"); PlayerInfo[playerid][pLevel] = strval(savingstring);
        
mysql_fetch_field_row(savingstring"vip"); PlayerInfo[playerid][pVIP] = strval(savingstring);
        
mysql_fetch_field_row(savingstring"kma"); PlayerInfo[playerid][pKMA] = strval(savingstring);
        
mysql_fetch_field_row(savingstring"Cookies"); PlayerInfo[playerid][pCookies] = strval(savingstring);
        
mysql_fetch_field_row(savingstring"rank"); PlayerInfo[playerid][pRank] = strval(savingstring);
        
mysql_fetch_field_row(savingstring"kills"); PlayerInfo[playerid][pKills] = strval(savingstring);
        
mysql_fetch_field_row(savingstring"deaths"); PlayerInfo[playerid][pDeaths] = strval(savingstring);
        
mysql_fetch_field_row(savingstring"muted"); PlayerInfo[playerid][pMuted] = strval(savingstring);
        
mysql_fetch_field_row(savingstring"jailed"); PlayerInfo[playerid][pJailed] = strval(savingstring);
        
mysql_fetch_field_row(savingstring"frozen"); PlayerInfo[playerid][pFrozen] = strval(savingstring);
        
mysql_fetch_field_row(savingstring"mutedtimes"); PlayerInfo[playerid][pMutedTimes] = strval(savingstring);
        
mysql_fetch_field_row(savingstring"jailedtimes"); PlayerInfo[playerid][pJailedTimes] = strval(savingstring);
        
mysql_fetch_field_row(savingstring"frozentimes"); PlayerInfo[playerid][pFrozenTimes] = strval(savingstring);
        
mysql_fetch_field_row(savingstring"logins"); PlayerInfo[playerid][pLogins] = strval(savingstring);
        
mysql_fetch_field_row(savingstring"posx"); PlayerInfo[playerid][pPosX] = strval(savingstring);
        
mysql_fetch_field_row(savingstring"posy"); PlayerInfo[playerid][pPosY] = strval(savingstring);
        
mysql_fetch_field_row(savingstring"posz"); PlayerInfo[playerid][pPosZ] = strval(savingstring);
        
mysql_fetch_field_row(savingstring"posa"); PlayerInfo[playerid][pPosA] = strval(savingstring);
    }
    
mysql_free_result();
    
JustLogged[playerid] = 1;
    
Logged[playerid] = 1;
    
PlayerInfo[playerid][pLogins]++;
    
GameTextForPlayer(playerid,"~g~You have succesfully ~n~logged in!",5000,5);
    new 
st[128];
    
format(st,128,"%s has joined SA-MP: DayZ ! Welcome back, %s!",GetName(playerid),GetName(playerid));
    
SendClientMessageToAll(COLOR_LIGHTBLUE,st);
    return 
1;

Reply
#2

Can you please post your mysql log here. You can locate this file inside your server folder.
Reply
#3

look i fixed that the new problem is when player register it don't save in the database

Logs:

Код:
[Sat Sep 10 21:02:16 2016] -------------------------
[Sat Sep 10 21:02:16 2016]      Logging Started
[Sat Sep 10 21:02:16 2016] -------------------------
[Sat Sep 10 21:02:16 2016] Function: mysql_init executed with result: "0".
[Sat Sep 10 21:02:16 2016] Connected (0) to root @ localhost via TCP/IP.
[Sat Sep 10 21:02:16 2016] MySQL Server Version 5.5.5-10.1.9-MariaDB.
[Sat Sep 10 21:02:16 2016] Auto reconnect is off.
[Sat Sep 10 21:02:16 2016] Function: mysql_stat executed with result: "Uptime: 372  Threads: 1  Questions: 793  Slow queries: 0  Opens: 22  Flush tables: 1  Open tables: 32  Queries per second avg: 2.131".
[Sat Sep 10 21:02:44 2016] Function: mysql_real_esacpe_string executed: "Nour" with result: "Nour".
[Sat Sep 10 21:02:44 2016] Function: mysql_query executed: "SELECT `nick` FROM `playerdata` WHERE `nick` COLLATE latin1_general_cs = 'Nour' LIMIT 1" with result: "0".
[Sat Sep 10 21:02:44 2016] Function: mysql_store_result executed with result: "1"
[Sat Sep 10 21:02:44 2016] Function: mysql_num_rows executed with result: "".
[Sat Sep 10 21:02:44 2016] Function: mysql_free_result executed.
[Sat Sep 10 21:02:52 2016] Function: mysql_real_esacpe_string executed: "Nour2004" with result: "Nour2004".
[Sat Sep 10 21:02:52 2016] Function: mysql_real_esacpe_string executed: "Nour" with result: "Nour".
[Sat Sep 10 21:02:52 2016] Function: mysql_real_esacpe_string executed: "127.0.0.1" with result: "127.0.0.1".
[Sat Sep 10 21:02:52 2016] Function: mysql_query executed: "INSERT INTO `playerdata` (`nick`, `password`, `ip`) VALUES('Nour', '207946347', '0', '0', '127.0.0.1')" with result: "1".
[Sat Sep 10 21:02:52 2016] Error (0): Failed to exeute query. Column count doesn't match value count at row 1.
[Sat Sep 10 21:03:10 2016] Function: mysql_real_esacpe_string executed: "N" with result: "N".
[Sat Sep 10 21:03:10 2016] Function: mysql_real_esacpe_string executed: "Nour" with result: "Nour".
[Sat Sep 10 21:03:10 2016] Function: mysql_query executed: "SELECT * FROM `playerdata` WHERE `nick` COLLATE latin1_general_cs = 'Nour' AND `password` = '5177423'" with result: "0".
[Sat Sep 10 21:03:10 2016] Function: mysql_store_result executed with result: "1"
[Sat Sep 10 21:03:10 2016] Function: mysql_num_rows executed with result: "".
[Sat Sep 10 21:03:10 2016] Function: mysql_free_result executed.
[Sat Sep 10 21:03:13 2016] Function: mysql_real_esacpe_string executed: "Nour2004" with result: "Nour2004".
[Sat Sep 10 21:03:13 2016] Function: mysql_real_esacpe_string executed: "Nour" with result: "Nour".
[Sat Sep 10 21:03:13 2016] Function: mysql_query executed: "SELECT * FROM `playerdata` WHERE `nick` COLLATE latin1_general_cs = 'Nour' AND `password` = '207946347'" with result: "0".
[Sat Sep 10 21:03:13 2016] Function: mysql_store_result executed with result: "1"
[Sat Sep 10 21:03:13 2016] Function: mysql_num_rows executed with result: "".
[Sat Sep 10 21:03:13 2016] Function: mysql_free_result executed.
[Sat Sep 10 21:03:16 2016] Function: mysql_real_esacpe_string executed: "Nour2004" with result: "Nour2004".
[Sat Sep 10 21:03:16 2016] Function: mysql_real_esacpe_string executed: "Nour" with result: "Nour".
[Sat Sep 10 21:03:16 2016] Function: mysql_query executed: "SELECT * FROM `playerdata` WHERE `nick` COLLATE latin1_general_cs = 'Nour' AND `password` = '207946347'" with result: "0".
[Sat Sep 10 21:03:16 2016] Function: mysql_store_result executed with result: "1"
[Sat Sep 10 21:03:16 2016] Function: mysql_num_rows executed with result: "".
[Sat Sep 10 21:03:16 2016] Function: mysql_free_result executed.
[Sat Sep 10 21:03:18 2016] Function: mysql_real_esacpe_string executed: " " with result: " ".
[Sat Sep 10 21:03:18 2016] Function: mysql_real_esacpe_string executed: "Nour" with result: "Nour".
[Sat Sep 10 21:03:18 2016] Function: mysql_query executed: "SELECT * FROM `playerdata` WHERE `nick` COLLATE latin1_general_cs = 'Nour' AND `password` = '2162721'" with result: "0".
[Sat Sep 10 21:03:18 2016] Function: mysql_store_result executed with result: "1"
[Sat Sep 10 21:03:18 2016] Function: mysql_num_rows executed with result: "".
[Sat Sep 10 21:03:18 2016] Function: mysql_free_result executed.
[Sat Sep 10 21:03:19 2016] Function: mysql_query executed: "UPDATE `playerdata` SET `admin` = '0', `score` = '0', `money` = '0', `kills` = '0', `deaths` = '0' WHERE `id` = '0' LIMIT 1" with result: "0".
[Sat Sep 10 21:03:42 2016] Function: mysql_real_esacpe_string executed: "Nour" with result: "Nour".
[Sat Sep 10 21:03:42 2016] Function: mysql_query executed: "SELECT `nick` FROM `playerdata` WHERE `nick` COLLATE latin1_general_cs = 'Nour' LIMIT 1" with result: "0".
[Sat Sep 10 21:03:42 2016] Function: mysql_store_result executed with result: "1"
[Sat Sep 10 21:03:42 2016] Function: mysql_num_rows executed with result: "".
[Sat Sep 10 21:03:42 2016] Function: mysql_free_result executed.
[Sat Sep 10 21:03:49 2016] Function: mysql_real_esacpe_string executed: "Nour2004" with result: "Nour2004".
[Sat Sep 10 21:03:49 2016] Function: mysql_real_esacpe_string executed: "Nour" with result: "Nour".
[Sat Sep 10 21:03:49 2016] Function: mysql_real_esacpe_string executed: "127.0.0.1" with result: "127.0.0.1".
[Sat Sep 10 21:03:49 2016] Function: mysql_query executed: "INSERT INTO `playerdata` (`nick`, `password`, `ip`) VALUES('Nour', '207946347', '0', '0', '127.0.0.1')" with result: "1".
[Sat Sep 10 21:03:49 2016] Error (0): Failed to exeute query. Column count doesn't match value count at row 1.
[Sat Sep 10 21:03:54 2016] Function: mysql_query executed: "UPDATE `playerdata` SET `admin` = '0', `score` = '0', `money` = '0', `kills` = '0', `deaths` = '0' WHERE `id` = '0' LIMIT 1" with result: "0".
[Sat Sep 10 21:16:23 2016] -------------------------
[Sat Sep 10 21:16:23 2016]      Logging Started
[Sat Sep 10 21:16:23 2016] -------------------------
Reply
#4

Код:
Function: mysql_query executed: "INSERT INTO `playerdata` (`nick`, `password`, `ip`) VALUES('Nour', '207946347', '0', '0', '127.0.0.1')" with result: "1".
Error (0): Failed to exeute query. Column count doesn't match value count at row 1.
3 columns and 5 values given which don't match.

---

Use default values when creating the table (or alter it and add them) so you can then just specify nick, password and ip and all the rest will be set automatically.
Reply
#5

why do you have LIMIT 1 on that second line. LIMIT 1 is not applicable for that type of query. And there where you 'insert', the values that you insert is not the same that you state inside the query.

Should be:

Код:
"INSERT INTO `playerdata` (`nick`, `password`, `ip`) VALUES('Nour', '207946347', '127.0.0.1')"
Reply
#6

Hey, edit my codes and send it
Reply
#7

Any one?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)