SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 10/06/2012, 07:23 AM   #1
SomebodyAndMe
Huge Clucker
 
SomebodyAndMe's Avatar
 
Join Date: Feb 2010
Location: 52.511938,6.092434 find it.
Posts: 471
Reputation: 21
Default MySQL not updating

Here's the code:
pawn Code:
new score = GetPlayerScore(playerid);
        new money = GetPlayerMoney(playerid);
        new query[1000], pname[24];
        GetPlayerName(playerid, pname, 24);
        format(query, sizeof(query), "UPDATE `PlayerData` SET Score='%d', Ip='%s', PlayerLevel='%d', StatsMetersDriven='%d', StatsTruckerJobs='%d', ", score,IP, APlayerData[playerid][PlayerLevel], APlayerData[playerid][StatsMetersDriven],APlayerData[playerid][StatsTruckerJobs]);
        format(query, sizeof(query), "StatsConvoyJobs='%d', StatsBusDriverJobs='%d', StatsPilotJobs='%d', StatsMafiaJobs='%d', ",APlayerData[playerid][StatsConvoyJobs],APlayerData[playerid][StatsBusDriverJobs],APlayerData[playerid][StatsPilotJobs],APlayerData[playerid][StatsMafiaJobs]);
        format(query, sizeof(query), "StatsMafiaStolen='%d', StatsPoliceFined='%d', StatsPoliceJailed='%d', StatsAssistance='%d', ",APlayerData[playerid][StatsMafiaStolen],APlayerData[playerid][StatsPoliceFined],APlayerData[playerid][StatsPoliceJailed],APlayerData[playerid][StatsAssistance]);
        format(query, sizeof(query), "StatsCourierJobs='%d', StatsRoadworkerJobs='%d', Money='%d', OFWarns='%d', TruckerLicense='%d', BusLicense='%d' WHERE `Name`='%s'", APlayerData[playerid][StatsCourierJobs],APlayerData[playerid][StatsRoadworkerJobs],money,APlayerData[playerid][OFWarns],APlayerData[playerid][TruckerLicense],APlayerData[playerid][BusLicense],pname);

        mysql_query(query);
    }

It doesn't update into the database, anyone know what's wrong in this code?
SomebodyAndMe is offline   Reply With Quote
Old 10/06/2012, 08:12 AM   #2
Calgon
Banned
 
Join Date: Jan 2009
Posts: 6,134
Reputation: 1127
Default Re: MySQL not updating

You re-format the query string every single time you use it. You didn't read what I posted in your other thread properly before.

pawn Code:
format(query, sizeof(query), "UPDATE `PlayerData` SET Score='%d', Ip='%s', PlayerLevel='%d', StatsMetersDriven='%d', StatsTruckerJobs='%d', ", score,IP, APlayerData[playerid][PlayerLevel], APlayerData[playerid][StatsMetersDriven],APlayerData[playerid][StatsTruckerJobs]);
        format(query, sizeof(query), "%s StatsConvoyJobs='%d', StatsBusDriverJobs='%d', StatsPilotJobs='%d', StatsMafiaJobs='%d', ", query, APlayerData[playerid][StatsConvoyJobs],APlayerData[playerid][StatsBusDriverJobs],APlayerData[playerid][StatsPilotJobs],APlayerData[playerid][StatsMafiaJobs]);
        format(query, sizeof(query), "%s StatsMafiaStolen='%d', StatsPoliceFined='%d', StatsPoliceJailed='%d', StatsAssistance='%d', ", query, APlayerData[playerid][StatsMafiaStolen],APlayerData[playerid][StatsPoliceFined],APlayerData[playerid][StatsPoliceJailed],APlayerData[playerid][StatsAssistance]);
        format(query, sizeof(query), "%s StatsCourierJobs='%d', StatsRoadworkerJobs='%d', Money='%d', OFWarns='%d', TruckerLicense='%d', BusLicense='%d' WHERE `Name`='%s'", query, APlayerData[playerid][StatsCourierJobs],APlayerData[playerid][StatsRoadworkerJobs],money,APlayerData[playerid][OFWarns],APlayerData[playerid][TruckerLicense],APlayerData[playerid][BusLicense],pname);

For the first format, simply write in to the string. For the other formats, you need to re-add the previous format() by collecting the current value of 'query' and using it again, adding on to it.
Calgon is offline   Reply With Quote
Old 10/06/2012, 10:00 AM   #3
SomebodyAndMe
Huge Clucker
 
SomebodyAndMe's Avatar
 
Join Date: Feb 2010
Location: 52.511938,6.092434 find it.
Posts: 471
Reputation: 21
Default Re: MySQL not updating

Thanks, and sorry for not reading completely through it.(other topic)
SomebodyAndMe is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MYSQL not updating? Nuke547 Scripting Help 3 17/04/2012 01:43 AM
MySql Not Updating aqu Scripting Help 0 26/02/2012 02:46 PM
Updating a mysql row ihatetn931 Help Archive 0 24/11/2010 11:53 AM
Updating Car [Mysql] Cameltoe Help Archive 10 14/08/2010 09:56 PM


All times are GMT. The time now is 03:29 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.