MySQL strange
#1

Код:
new slot[12];
format(slot, sizeof(slot), "%s", GetPlayerAvailableSlot(playerid));
SetPVarInt(playerid, slot, vehicleid);
format(message, sizeof(message), "UPDATE members SET %s='%d' WHERE Username = '%s'", slot, vehicleid, getname[playerid]);
printf(message);
mysql_query(connectionHandle, message);
That printf:
Quote:

UPDATE members SET VEHICLE2='177' WHERE Username = '[A]AfikAtashga[S]'

In the mysql it's always write 127 - it's very strange.

Thanks for helping.
Reply
#2

Someone?
Reply
#3

Maybe instead of %s try using %e.
Reply
#4

Quote:
Originally Posted by kamiliuxliuxliux
Посмотреть сообщение
Maybe instead of %s try using %e.
I dont think so, see what i wrote in the "printf" part.
It's exactly what it need to do, but no metter what, it's always changed to 127. I search in the mode, and there is no any line that should do that.

Help!
Reply
#5

Quote:

UPDATE members SET VEHICLE2='177' WHERE Username = '[A]AfikAtashga[S]'

I don't see any 127. Show the code of how vehicleid variable was set when getting the vehicleid?
Reply
#6

Field is probably set to tinyint. MySQL forces values in range. But you should probably rethink your database design anyway. Adding a number to a field name is bad. Using a string as a key is bad.
Reply
#7

Quote:
Originally Posted by Zex Tan
Посмотреть сообщение
I don't see any 127. Show the code of how vehicleid variable was set when getting the vehicleid?
Код:
stock GetPlayerAvailableSlot(playerid)
{
	for(new i = 1, j = MAX_PLAYER_VEHICLES; i <= j; i++)
	{
	    format(smallmessage, sizeof(smallmessage), "VEHICLE%d", i);
	    if(GetPVarInt(playerid, smallmessage) == -1) return smallmessage;
	}
	return smallmessage;
}
Quote:
Originally Posted by Vince
Посмотреть сообщение
Field is probably set to tinyint. MySQL forces values in range. But you should probably rethink your database design anyway. Adding a number to a field name is bad. Using a string as a key is bad.
If i'll change the field to smallint you think it work? because when i tried to do:
Код:
format(message, sizeof(message), "UPDATE members SET %s='%d' WHERE Username = '%s'", slot, 100, getname[playerid]);
It work & put 100 in the field.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)