Mysql ? wierd?
#1

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

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

OMG lol thanks man that's realy stupid of me
Reply
#4

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

It doesn't matter. I use the single quotes around every value and I've never experienced any problems with it.
Reply
#6

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


Forum Jump:


Users browsing this thread: 1 Guest(s)