SA-MP Forums Archive
problem mysql_retrieve_row - 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: problem mysql_retrieve_row (/showthread.php?tid=512768)



problem mysql_retrieve_row - jcvag44800 - 12.05.2014

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


Re: problem mysql_retrieve_row - Vince - 12.05.2014

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.


Re : problem mysql_retrieve_row - jcvag44800 - 12.05.2014

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