SA-MP Forums Archive
Mysql saving - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Mysql saving (/showthread.php?tid=571078)



Mysql saving - iBots - 15.04.2015

i made a system for saving and loading,it loads right but when i save it saves wrong ,everything gets messed,like num stays 3 while it has been set to 0,here is the code
pawn Код:
forward SaveIds();
public SaveIds()
{
    for(new id = 0; id < MAX_IDS; id++)
    {
            new query[128];
            mysql_format(mysqlquery, query, sizeof(query), "UPDATE `ids` SET `IDSet`=%d, `IDDone`=%d, `IDPosX`=%f, `IDPosY`=%f, `IDPosZ`=%f,`IDPosA`=%f, `IDNum`=%d, `IDAmount`=%d, `IDType`=%d, `IDTypename`='%s', `IDMoveX`=%f, `IDMoveY`=%f, `IDMoveZ`=%f  WHERE `ID`=%d",
            IdInfo[id][idset], IdInfo[id][iddone], IdInfo[id][idposx], IdInfo[id][idposy], IdInfo[id][idposz],
            IdInfo[id][idposa], IdInfo[id][idnum], IdInfo[id][idamount], IdInfo[id][idtype], IdInfo[id][idtypename]
             ,IdInfo[id][idmovex], IdInfo[id][idmovey], IdInfo[id][idmovez], id);
            printf("\n %s", query);
            mysql_tquery(mysqlquery, query);
            printf("Saved ID %d", id);
    }
    return 1;
}
NOTE:it prints the query right but saves wrong in database


Re: Mysql saving - iBots - 16.04.2015

Anyone?


Re: Mysql saving - iBots - 16.04.2015

Anyone?come on


Re: Mysql saving - Darrenr - 16.04.2015

Have you copied the query that it prints to the console and then tried running that from within phpmyadmin or sometihng? just to make 100% sure that the query syntax is correct?


Re: Mysql saving - MEW273 - 16.04.2015

Quote:
Originally Posted by iBots
Посмотреть сообщение
NOTE:it prints the query right but saves wrong in database
Hi iBots,

Can you please show us what is printed in the server log?


Re: Mysql saving - iiNzTicTx - 16.04.2015

1. For all string output values to mySQL I would recommend using %e, instead of %s when formatting strings. This will increase security and avoid SQL injections.
2. Enable SQL debugging: mysql_debug(); under OnGameModeinit. Then, open mysql_log.txt in your server root and paste the result. Perhaps you have an invalid field type in your table?

Is it saving at all?