Not Update
#1

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, "", "");
Reply
#2

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.
Reply
#3

Quote:
Originally Posted by Maximus0
View Post
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.
Reply
#4

Integers aren't set like strings are. There shouldn't be any ' in the SET string(relating to the = expression).

Example:
Your code:
pawn Code:
`Slot` = '1'
Proper code:
pawn Code:
`Slot` = 1
And as Sime30 stated, what is the purpose of updating when you can just insert all the needed data simple as?
Reply
#5

Quote:
Originally Posted by Sime30
View Post
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``
Reply
#6

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 =>
Reply
#7

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
Reply
#8

Can you post mysql_log?
Reply
#9

Quote:
Originally Posted by WopsS
View Post
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"');
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)