Not Update -
norton2 - 05.02.2015
I do not updating ! The insert is inserted , but not updating
HTML Code:
new query[512], idc;
idc = PlayerInfo[playerid][pID];
new Float:pos1 = 494.3450;
new Float:pos2 = -1022.9496;
new Float:pos3 = 31.8931;
new Float:angle = 184.0622;
VehiclesInfo[TotalVeh][vServerID] = CreateVehicle(modelid, 494.3450, -1022.9496, 31.8931, 184.0622, 1, 1, 60000);
PutPlayerInVehicle(playerid, VehiclesInfo[TotalVeh][vServerID], 0);
format(query,300,"INSERT INTO `vehicles` (`Model`,`PositionX`,`PositionY`,`PositionZ`,`Angle`,`Owner`, `ServerID`, `Slot`) \
VALUES ('%d', '%f', '%f', '%f', '%f', '%i', '%i', '1')",modelid,pos1,pos2,pos3,angle,idc, VehiclesInfo[TotalVeh][vServerID]);
mysql_query(handle, query);
mysql_format(handle, query, sizeof(query), "UPDATE vehicles SET Owner = '%i', ServerID = '%i', Slot = '1' WHERE ID = '%i'", idc, VehiclesInfo[TotalVeh][vServerID], VehiclesInfo[TotalVeh][vID]);
mysql_tquery(handle, query, "", "");
Re: Not Update -
Maximus0 - 05.02.2015
pawn Code:
mysql_format(handle, query, sizeof(query), "UPDATE `vehicles` SET `Owner` = '%i', `ServerID` = '%i', `Slot` = '1' WHERE `ID` = '%i'", idc, VehiclesInfo[TotalVeh][vServerID], VehiclesInfo[TotalVeh][vID]);
mysql_tquery(handle, query, "", "");
Try this.
Re: Not Update -
Sime30 - 06.02.2015
Quote:
Originally Posted by Maximus0
pawn Code:
mysql_format(handle, query, sizeof(query), "UPDATE `vehicles` SET `Owner` = '%i', `ServerID` = '%i', `Slot` = '1' WHERE `ID` = '%i'", idc, VehiclesInfo[TotalVeh][vServerID], VehiclesInfo[TotalVeh][vID]); mysql_tquery(handle, query, "", "");
Try this.
|
That's the same as his.
OT: Why are you inserting and then updating? Immediately insert all values.
Re: Not Update -
Abagail - 06.02.2015
Integers aren't set like strings are. There shouldn't be any ' in the SET string(relating to the = expression).
Example:
Your code:
Proper code:
And as Sime30 stated, what is the purpose of updating when you can just insert all the needed data simple as?
Re: Not Update -
Maximus0 - 06.02.2015
Quote:
Originally Posted by Sime30
That's the same as his.
OT: Why are you inserting and then updating? Immediately insert all values.
|
If you had little sense to check he forgot to add
``. I ain't a farmer to post randomly.
Here without
``
With
``
Re: Not Update -
norton2 - 06.02.2015
ID is not correct. How do you find the car that machine ID from the database ?
I did this:
GameMode:
HTML Code:
printf("Owner:%i | SID: %i | ID: %i",idc, VehiclesInfo[TotalVeh][vServerID], VehiclesInfo[v][vID]); //debug
server.log:
HTML Code:
[00:31:26] Owner:17 | SID: 337 | ID: 0
ID is incorrect!
Correct ID is: 33 =>
Re: Not Update -
HazardouS - 06.02.2015
pawn Code:
mysql_format(handle, query, sizeof(query), "UPDATE vehicles SET Owner = '%i', ServerID = '%i', Slot = '1' WHERE ID = '%i'", idc, VehiclesInfo[TotalVeh][vServerID], VehiclesInfo[TotalVeh][vID]);
Obviously, the last variable, VehiclesInfo[TotalVeh][vID], does not store the correct database ID. I'm guessing that vID gets updated when the vehicles load from database, so you will have to update it manually after adding the vehicle with something like this:
https://sampwiki.blast.hk/wiki/MySQL/R33#cache_insert_id
Re: Not Update -
WopsS - 06.02.2015
Can you post
mysql_log?
Re: Not Update -
Maximus0 - 06.02.2015
Quote:
Originally Posted by WopsS
Can you post mysql_log?
|
Why do you seriously need mysql_log?
__________________
norton2, After you have send the query to work. You can get the ID what your query has inserted. Something like this.
pawn Code:
mysql_query(handle, query);
YouID = mysql_insert_id( );
printf("Inserted ID is'"YouID"');