Mysql ? wierd? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Mysql ? wierd? (
/showthread.php?tid=227459)
Mysql ? wierd? -
KaleOtter - 17.02.2011
Hello, I tried almost 100 times with different strings but it never will work I gues.
The VehicleNumber keeps on 0...
I have this:
Код:
public SaveVehicles()
{
mysql_query("SELECT VehicleNumber FROM vehicles");
mysql_store_result();
new SetNumber[256];
for(new id=0; id<mysql_num_rows(); id++)
{
format(SetNumber,sizeof(SetNumber),"UPDATE `vehicles` SET VehicleNumber = %d WERE id = %d",vStats[id][VehicleNumber],id);
printf("%d",vStats[id][VehicleNumber]);
mysql_query(SetNumber);
}
mysql_free_result();
return 1;
}
Print:
[17:32:03] UPDATE `vehicles` SET VehicleNumber = 975697581 WERE id = 415
And yes my database is working
And yes those colums exist
And yes I don't see any mistake in this string...
Re: Mysql ? wierd? -
Criss_Angel - 17.02.2011
It should be:
pawn Код:
format(SetNumber,sizeof(SetNumber),"UPDATE `vehicles` SET `VehicleNumber` = '%d' WHERE id = '%d'",vStats[id][VehicleNumber],id);
U forgot a H in WERE
And you should add a '' Infront and at the end of a value AND IT should be `VehicleNumber`
Re: Mysql ? wierd? -
KaleOtter - 17.02.2011
OMG lol thanks man that's realy stupid of me
Re: Mysql ? wierd? -
Blacklite - 17.02.2011
Quote:
Originally Posted by Criss_Angel
It should be:
pawn Код:
format(SetNumber,sizeof(SetNumber),"UPDATE `vehicles` SET `VehicleNumber` = '%d' WHERE id = '%d'",vStats[id][VehicleNumber],id);
U forgot a H in WERE
And you should add a '' Infront and at the end of a value AND IT should be `VehicleNumber`
|
no, you only need to use apostrophes (') for string values, int/decimal do not need them
Re: Mysql ? wierd? -
Vince - 17.02.2011
It doesn't matter. I use the single quotes around every value and I've never experienced any problems with it.
Re: Mysql ? wierd? -
Blacklite - 17.02.2011
Quote:
Originally Posted by Vince
It doesn't matter. I use the single quotes around every value and I've never experienced any problems with it.
|
yes but his post implied they were
required for ints, i was simply clearing that up.