SA-MP Forums Archive
[Ajuda] MYSQL: Error #1064 - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] MYSQL: Error #1064 (/showthread.php?tid=532999)



MYSQL: Error #1064 - DreyPT - 21.08.2014

Alguйm pode ajudar?

Error #1064 - Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `vehicleIDz` = '2' at line 1 | Query: UPDATE `vehicles` SET `veh_Taken` = '1', `veh_Int` = '0', `veh_VW` = '0', `veh_Model` = '411', `veh_Color1` = '1', `veh_Color2` = '1', `veh_Job` = '-1', `veh_PosX` = '2127.950439', `veh_PosY` = '-2234.885742', `veh_PosZ` = '13.117015', `veh_PosA` = '133.926864', `veh_Faction` = '-1', `veh_Family` = '-1', `veh_Kilometros` = '0', `veh_Metros` = '0.000000', WHERE `vehicleIDz` = '2


Код:
stock SaveVehicle(vehicleID)
{
    format(szQuery, sizeof(szQuery), "UPDATE `vehicles` SET `veh_Taken` = '%d', `veh_Int` = '%d', `veh_VW` = '%d', `veh_Model` = '%d', `veh_Color1` = '%d', `veh_Color2` = '%d', `veh_Job` = '%d', `veh_PosX` = '%f'", VehicleData[vehicleID][veh_Taken], VehicleData[vehicleID][veh_INT], VehicleData[vehicleID][veh_VW], VehicleData[vehicleID][veh_Model], VehicleData[vehicleID][veh_Color1], VehicleData[vehicleID][veh_Color2], VehicleData[vehicleID][veh_Job], VehicleData[vehicleID][veh_OutsidePosition][0]);
    format(szQuery, sizeof(szQuery), "%s, `veh_PosY` = '%f', `veh_PosZ` = '%f', `veh_PosA` = '%f', `veh_Faction` = '%i', `veh_Family` = '%d', `veh_Kilometros` = '%d'", szQuery, VehicleData[vehicleID][veh_OutsidePosition][1], VehicleData[vehicleID][veh_OutsidePosition][2], VehicleData[vehicleID][veh_OutsidePosition][3], VehicleData[vehicleID][veh_Faction], VehicleData[vehicleID][veh_Family], VehicleData[vehicleID][veh_Staff], VehicleData[vehicleID][veh_Kilometros]);
    format(szQuery, sizeof(szQuery), "%s, `veh_Metros` = '%d'  WHERE `vehicleIDz` = '%d", szQuery, VehicleData[vehicleID][veh_Metros], vehicleID);
    return mysql_function_query(MainPipeline, szQuery, true, "OnQueryFinish", "ii", THREAD_NO_RESULT, vehicleID);
}



Re: MYSQL: Error #1064 - n0minal - 21.08.2014

Nao faltou um %s no 2° format para inserir a 1Є string na 2Є?


Re: MYSQL: Error #1064 - DreyPT - 21.08.2014

Quote:
Originally Posted by DreyPT
Посмотреть сообщение
Код:
stock SaveVehicle(vehicleID)
{
    format(szQuery, sizeof(szQuery), "UPDATE `vehicles` SET `veh_Taken` = '%d', `veh_Int` = '%d', `veh_VW` = '%d', `veh_Model` = '%d', `veh_Color1` = '%d', `veh_Color2` = '%d', `veh_Job` = '%d', `veh_PosX` = '%f'", VehicleData[vehicleID][veh_Taken], VehicleData[vehicleID][veh_INT], VehicleData[vehicleID][veh_VW], VehicleData[vehicleID][veh_Model], VehicleData[vehicleID][veh_Color1], VehicleData[vehicleID][veh_Color2], VehicleData[vehicleID][veh_Job], VehicleData[vehicleID][veh_OutsidePosition][0]);
    format(szQuery, sizeof(szQuery), "%s, `veh_PosY` = '%f', `veh_PosZ` = '%f', `veh_PosA` = '%f', `veh_Faction` = '%i', `veh_Family` = '%d', `veh_Kilometros` = '%d'", szQuery, VehicleData[vehicleID][veh_OutsidePosition][1], VehicleData[vehicleID][veh_OutsidePosition][2], VehicleData[vehicleID][veh_OutsidePosition][3], VehicleData[vehicleID][veh_Faction], VehicleData[vehicleID][veh_Family], VehicleData[vehicleID][veh_Staff], VehicleData[vehicleID][veh_Kilometros]);
    format(szQuery, sizeof(szQuery), "%s, `veh_Metros` = '%d'  WHERE `vehicleIDz` = '%d", szQuery, VehicleData[vehicleID][veh_Metros], vehicleID);
    return mysql_function_query(MainPipeline, szQuery, true, "OnQueryFinish", "ii", THREAD_NO_RESULT, vehicleID);
}
Eu corrigi no tуpico, jб coloquei a string em condiзхes.. Mas continua a dar o erro Error #1064 - Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''2' at line 1 | Query: UPDATE `vehicles` SET `veh_Taken` = '1', `veh_Int` = '0', `veh_VW` = '0', `veh_Model` = '411', `veh_Color1` = '1', `veh_Color2` = '1', `veh_Job` = '-1', `veh_PosX` = '9.640727', `veh_PosY` = '4.653275', `veh_PosZ` = '2.855726', `veh_PosA` = '359.583160', `veh_Faction` = '-1', `veh_Family` = '-1', `veh_Kilometros` = '0', `veh_Metros` = '0' WHERE `vehicleIDz` = '2


Re: MYSQL: Error #1064 - Schocc - 21.08.2014

Vocк esta formatando a query mas na ultima linha a string sу tem isso armazenado.
Quote:

"`veh_PosY` = '%f', `veh_PosZ` = '%f', `veh_PosA` = '%f', `veh_Faction` = '%i', `veh_Family` = '%d', `veh_Kilometros` = '%d', `veh_Metros` = '%f' WHERE `vehicleIDz` = '%d"

Faltou usar strcat

Alias, o problema esta na concatenaзгo da string szQuery.


Re: MYSQL: Error #1064 - n0minal - 21.08.2014

Quote:
Originally Posted by Schocc
Посмотреть сообщение
Vocк esta formatando a query mas na ultima linha a string sу tem isso armazenado.


Faltou usar strcat

Alias, o problema esta na concatenaзгo da string szQuery.
Da pra fazer por format tbm... Se a sintaxe SQL ta incorreta provavelmente foi mesmo nessa concatenacao.


@Edit nao falta um ' no final? Talvez a string esteja pequena caso tenha colocado...


Re: MYSQL: Error #1064 - DreyPT - 21.08.2014

Quote:
Originally Posted by n0minal
Посмотреть сообщение
Da pra fazer por format tbm... Se a sintaxe SQL ta incorreta provavelmente foi mesmo nessa concatenacao.


@Edit nao falta um ' no final? Talvez a string esteja pequena caso tenha colocado...
Exacto, falta!

Jб estб a funcionar! As coisas mais pequenas, sгo as que dгo mais problema.. damn! haha

obrigado!


Re: MYSQL: Error #1064 - n0minal - 21.08.2014

pois eh amigo, os menores detalhes sempre causam problemas e passam despercebidos, disponha xD


Re: MYSQL: Error #1064 - PT - 21.08.2014

Quote:
Originally Posted by n0minal
Посмотреть сообщение
Da pra fazer por format tbm... Se a sintaxe SQL ta incorreta provavelmente foi mesmo nessa concatenacao.


@Edit nao falta um ' no final? Talvez a string esteja pequena caso tenha colocado...
nas versoes mais recentes tem o mysql_format que facilita muito isso.