08.05.2014, 11:00
Hello,
I have 3 questions about Mysql.
NB: I use BlueG's R6 plugin.
1st question:
To check if a value exists in a table, I make this:
That is correct ?
2nd question:
For insert a value in a table, I make this:
3rd question:
To acquire data from database and put them in variables, I make this:
I think it's not correct because I got -1 value...
Regards
I have 3 questions about Mysql.
NB: I use BlueG's R6 plugin.
1st question:
To check if a value exists in a table, I make this:
Code:
new nplayer[MAX_PLAYER_NAME+1]; GetPlayerName(playerid, nplayer, sizeof(nplayer)); mysql_query(query,sizeof(query),"SELECT COUNT * FROM players WHERE Names = %s",nplayer);
2nd question:
For insert a value in a table, I make this:
Code:
format(query, sizeof(query), "INSERT INTO players (Name, Password) VALUES ('%s', '%s')", sqlplyname, sqlpassword); mysql_query(query);
To acquire data from database and put them in variables, I make this:
Code:
format(query,sizeof(query),"SELECT PlayerLevel FROM players WHERE id = %d LIMIT 1",PlayerInfo[playerid][pSQLID]); mysql_query(query); mysql_store_result(); tmp = mysql_fetch_int(); PlayerInfo[playerid][pLevel] = tmp; mysql_free_result();
Regards