Questions about mysql
#1

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:

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);
That is correct ?

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);
3rd question:

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();
I think it's not correct because I got -1 value...

Regards
Reply


Messages In This Thread
Questions about mysql - by jcvag44800 - 08.05.2014, 11:00
Re: Questions about mysql - by Roel - 08.05.2014, 11:41

Forum Jump:


Users browsing this thread: 1 Guest(s)