#1

Was creating a new column for my new system.
Anyways i filled all the sections except this one. I am not sure what it is.
http://gyazo.com/1bd2377f9a7947f2eab5dcaa15e91141
Index.
Should i set it as primary or what?
P.S. I might have posted in a wrong section. If so, sorry for that.
Reply
#2

If you have an ID field for example, setting that field as Primary will make it the identifier for the row. No other row will be able to have the same ID as another row, since it's the unique identifier for the row.

So, if the field you're trying to set index for is supposed to act like an unique identifier, set it as Primary.
Reply
#3

If your column is a key ---> choose primary key (like an ID or whatever) else kept it empty if you want!
Reply
#4

You should really consider reading more about SQL: https://dev.mysql.com/doc/refman/5.5...n-indexes.html
Reply
#5

Ahh i got it now. Thanks
ANyways i made a column. Whenever you write your email it supposed to insert into the E-Mail column which i just created but instead it just create a new section with the email only.
Here is the code:
Код:
SQL_SubmitEmail(playerid, string[]) // there should be a " , playerid) "
{
	new
	    query[512],name[32];
	GetPlayerName(playerid,name,sizeof(name));
//	format(query, sizeof(query), "INSERT INTO `accounts` (`ID`, `E-Mail`) VALUES('%d', '%s')", PlayerData[playerid][pID], string);
	format(query,sizeof(query), "INSERT INTO `accounts` (`ID`, `E-Mail`) VALUES('%d', '%s')", PlayerData[playerid][pID], string);
	mysql_tquery(g_iHandle, query);
}
and here is a photo too
http://gyazo.com/adf69d119ca73ea62d16175783207447
Not sure if this code is needed too.
Код:
SQL_CreateAccount(const username[], const password[])
{
	new
	    query[512],
	    buffer[129];

	WP_Hash(buffer, sizeof(buffer), password);

	format(query, sizeof(query), "INSERT INTO `accounts` (`Username`, `Password`, `RegisterDate`, `LoginDate`) VALUES('%s', '%s', '%s', '%s')", username, buffer, ReturnDate(), ReturnDate());
	mysql_tquery(g_iHandle, query);
}
Reply
#6

You already insert a new row so use UPDATE statement instead and set `E-Mail` field WHERE `ID` is known.

And have "ID" field PRIMARY KEY with AUTO INCREMENT.
Reply
#7

OKay i replaced it with UPDATE and ID field already has A_I and PRIMARY KEY
But now it wont even update the E-Mail field. It just stays null
Код:
	format(query,sizeof(query), "UPDATE `accounts` (`ID`, `E-Mail`) WHERE (`ID`) VALUES('%d', '%s')", PlayerData[playerid][pID], string);
http://gyazo.com/82b107272525be2d04e2ee4221f22f12
Reply
#8

The syntax is totally different - as I said before: read more about SQL: https://dev.mysql.com/doc/refman/5.0/en/update.html

and I'm pretty sure it's not A_I as it started from -1 when by default, they start from 1 (plus I see no reason you would have set another starting value to it).
Reply
#9

It is A_I
http://gyazo.com/bdccc1c4ecc539950e57eb221c91bf51
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)