Problem with mysql
#1

Hi everyone.

I have a problem with a query(Update).
I doesn't find the problem

My query:

pawn Код:
public UpdateVehicule()
{
  for(new v=1;v<NbVeh;v++)
  {
    if(VehInfo[v][VehID] != INVALID_VEH_ID)
    {
         new query[1028];
         format(query, sizeof(query), "UPDATE vehicule SET Model=%d, XSpawn='%f', YSpawn='%f', ZSpawn='%f', ASpawn='%f', Couleur1=%d, Couleur2=%d, Prix=%d, Lock=%d, Status=%d, Essence=%d, MaxEssence=%d, Kilometrage=%d, Proprietaire=%s WHERE VehID=%d LIMIT 1",
         VehInfo[v][Model],VehInfo[v][XSpawn],VehInfo[v][YSpawn],VehInfo[v][ZSpawn],
         VehInfo[v][ASpawn],VehInfo[v][Couleur1],VehInfo[v][Couleur2],VehInfo[v][Prix],
         VehInfo[v][Lock], VehInfo[v][Status],VehInfo[v][Essence], VehInfo[v][MaxEssence],
         VehInfo[v][Kilometrage], VehInfo[v][Proprietaire], VehInfo[v][VehID]);
         mysql_query(query);
         printf("---- Vehicule %d sauvegarder! ----",v);
    }
  }
  return 1;
}
And the mysql logs:

Quote:

[09:32:31] CMySQLHandler::Query(UPDATE vehicule SET Model=567, XSpawn='-251.354995', YSpawn='1879.030029', ZSpawn='42.289100', ASpawn='227.520996', Couleur1=50, Couleur2=46, Prix=0, Lock=1, Status=0, Essence=0, MaxEssence=0, Kilometrage=0, Proprietaire=Aucun WHERE VehID=3 LIMIT 1) - An error has occured. (Error ID: 1064, 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 'Lock=1, Status=0, Essence=0, MaxEssence=0, Kilometrage=0, Proprietaire=Aucun WHE' at line 1)

[09:32:39] >> mysql_real_escape_string( Connection handle: 1 )

Reply
#2

Quote:

format(query, sizeof(query), "UPDATE vehicule SET Model=%d, XSpawn='%f', YSpawn='%f', ZSpawn='%f', ASpawn='%f', Couleur1=%d, Couleur2=%d, Prix=%d, Lock=%d, Status=%d, Essence=%d, MaxEssence=%d, Kilometrage=%d, Proprietaire=%s WHERE VehID=%d LIMIT 1",

there your problem, its a String, use '%s' instead

Change your Proprietaire=%s into Proprietaire='%s'

hope this help..
Reply
#3

Thank you but it still does not work :/
Reply
#4

You don't need apostrophe's around anything but a string. So, where you have '%f', it should be %f. Where you have %s, it should be '%s'.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)