MySQL - Saving an array with multiple integer values?
#1

Right, so I'm wanting to save specific item ID's contained in an inventory using an integer array. Pretty simple.. although this ain't working. At all. I've only just converted over to using MySQL from dini so I'm not very familiar with php. Is this even possible with MySQL? Any help would be quite wonderful.

Код:
 	new cnt;
 	while(cnt <= 35) //Max Business inventory slots
	{
		format(query, sizeof(query),"UPDATE `businesses` SET `Inventory[%d]`= %d WHERE `SQLID`= %d ;",cnt, -1 ,i);
		mysql_query(query);
		cnt++;
	}
SQL Error log:
Код:
[00:12:12] CMySQLHandler::Query(UPDATE `businesses` SET `Inventory (35)`= '-1' WHERE `SQLID`=2 ;) - An error has occured. (Error ID: 1054, Unknown column 'Inventory[35]' in 'field list')
[00:12:12] >> mysql_query( Connection handle: 1 )
I've considered just creating a new column for each of the 35 values but I appreciate things being more organized if I can help it.
Reply
#2

faill.. learn mysql and come back later u cant have array like that lol
Reply
#3

Indeed, create more tables.
Reply
#4

Alright, thanks for the response guys.

-Resolved.
Reply
#5

You could also do this...

Код:
format(query, sizeof(query),"UPDATE `businesses` SET `Inventory`= %d %d %d %d WHERE `SQLID`= %d ;",
cnt[0], cnt[1], cnt[2], cnt[3], i);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)