No save Mysql ?
#1

My code:
PHP код:
SavePlayer(playerid)
{
    new 
query[3000], date[6], gslot[5], aslot[5], FloathealthFloatarmourstring[20], Float:PosX,    Float:PosY,    Float:PosZ,    Float:PosA;
    
    if(
Logged[playerid])
    {
         
        
GetPlayerPos(playerid,PosX,PosY,PosZ);
        
GetPlayerFacingAngle(playerid,PosA);
        
GetPlayerWeaponData(playerid2gslot[0], aslot[0]);
        
GetPlayerWeaponData(playerid3gslot[1], aslot[1]);
        
GetPlayerWeaponData(playerid4gslot[2], aslot[2]);
        
GetPlayerWeaponData(playerid5gslot[3], aslot[3]);
        
GetPlayerWeaponData(playerid6gslot[4], aslot[4]);
        
getdate(date[0], date[1], date[2]);
        
gettime(date[3], date[4], date[5]);
        
GetPlayerHealth(playeridhealth);
        
GetPlayerArmour(playeridarmour);
        
format(stringsizeof(string), "%d/%d/%d %d:%d:%d"date[0], date[1], date[2], date[3], date[4], date[5]); // last login date
        
//////////////////////////////Thong Tin Co Ban//////////////////////////////////
        
mysql_format(mysqlquerysizeof(query), "UPDATE `taikhoan` SET `Admin`=%d, `SkinID`=%d, `AccountLocked`=%d, `AccountBanned`=%d, `BanningAdmin`='%s', `BannedReason`='%s', `Tien`=%d, `TienBank`=%d, `Health`=%f, `Armour`=%f, `LastActivity`='%s' WHERE `ID`=%d",
        
Player[playerid][Admin], GetPlayerSkin(playerid), Player[playerid][AccountLocked], Player[playerid][AccountBanned], Player[playerid][BanningAdmin], Player[playerid][BannedReason], GetPlayerMoney(playerid), Player[playerid][TienBank], healtharmourstringPlayer[playerid][ID]); // Updating the table
////////////////////////////////////Positions///////////////////////////////////
        
mysql_format(mysqlquerysizeof(query), "UPDATE `taikhoan` SET `PosX`=%f, `PosY`=%f, `PosZ`=%f, `PosA`=%f WHERE `ID`=%d",\
        
PosXPosYPosZPosAPlayer[playerid][ID]);
////////////////////////////////////Weapons/////////////////////////////////////
        
mysql_format(mysqlquerysizeof(query), "UPDATE `taikhoan` SET `WeaponSlot1`=%d, `WepSlotAmmo1`=%d, `WeaponSlot2`=%d, `WepSlotAmmo2`=%d, `WeaponSlot3`=%d, `WepSlotAmmo3`=%d, `WeaponSlot4`=%d, `WepSlotAmmo4`=%d, `WeaponSlot5`=%d, `WepSlotAmmo5`=%d WHERE `ID`=%d",
        
gslot[0], aslot[0], gslot[1], aslot[1], gslot[2], aslot[2], gslot[3], aslot[3], gslot[4], aslot[4], Player[playerid][ID]); // Updating the table
        
mysql_tquery(mysqlquery""""); // Execute the query
    
}
    return 
1;

Help me.Sorry my bad english.
Reply
#2

Any errorlogs? ( server logs & sql logs )
Reply
#3

We need some sql logs, anyway you can try to print the query on server console and then paste it directly into your DBMS, it should give you some error and then it's easier to make it work. This is just my suggestion.
Reply
#4

If you have set the "LastActivity" column as "datetime" in MySQL:
PHP код:
    // Get the current date, time
    
getdate(YearMonthDay);
    
gettime(HourMinuteSecond);
    
// Construct the complete date to be added to MySQL for the registration date+time
    
format(Datesizeof(Date), "%04d-%02d-%02d %02d:%02d:%02d"YearMonthDayHourMinuteSecond); 
You need to add the "02" and "04" values to the structure of the date and time.
MySQL expects this structure where all values are 2 characters or 4 characters long.
If you would have the 1st of January, your string would end up like "2016-1-1 0:0:9" for example, when the time is only 9 seconds past midnight, while MySQL expects "2016-01-01 00:00:09".

This won't apply if that column is set a varchar of course, only for datetime.

See if this does the trick.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)