problem mysql_retrieve_row
#1

Hello,

This is my code:

Код:
    mysql_query("SELECT * FROM cars");
    mysql_store_result();
    new i=1,query[256];
	while(mysql_retrieve_row())
	{
		format(query,sizeof(query),"UPDATE cars SET realid='%d' ",i);
	    mysql_query(query);
        i++;
	}
He have to set a ID for any cars in my database.
So, car1 = 1 car2 = 2 car4=4 etc...

But, I have this: car1=1 (when I create the first), but when I create a second car, I got this: car1= 2 car2 = 2

I don't know why...
Regards
Reply
#2

You don't have a WHERE clause which means the query applies to the entire table. But you should probably turn your system the other way around, anyway. Save the vehicle's non-dynamic SQL ID in a Pawn variable rather than a dynamic Pawn variable in the database.
Reply
#3

Hello,

The problem, is when I do that:

Код:
format(query,sizeof(query),"UPDATE cars SET realid='%d' WHERE id=%d",i,CarInfo[i][cID]);
mysql_query(query);
(id is a auto increment)
The "realid" variable is not set.
Exemple:

Car1=1
Car2=2
Car3=3

When I delete Car2

Car1=1
Car3=3

I want

Car1=1
Car3=2

So the script set the ID 2 to Car2 who is removed...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)