SA-MP Forums Archive
MySQL strange - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL strange (/showthread.php?tid=521520)



MySQL strange - AfikAtashga - 23.06.2014

Код:
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.


Re: MySQL strange - AfikAtashga - 24.06.2014

Someone?


Re: MySQL strange - kamiliuxliuxliux - 24.06.2014

Maybe instead of %s try using %e.


Re: MySQL strange - AfikAtashga - 24.06.2014

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!


Re: MySQL strange - Zex Tan - 24.06.2014

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?


Re: MySQL strange - Vince - 24.06.2014

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.


Re: MySQL strange - AfikAtashga - 24.06.2014

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.