[SOLVED] Storing variables from MySQL
#1

Hello,

Can someone help me on this: (I've searched forums, already)

- I would like to set variables in the samp script with values which will be fetched from my mysql database.
Now the thing is, I don't know how to do it. I have some gamemodes with mysql who do it in a different way, but I don't understand their method, the way things are done.
Example
Код:
PlayerInfo[playerid][Level] = "mysql value here"
So that's what I want to do. Now this is what I've found:
Код:
SendQuery(szQuery);

  mysql_store_result();

  if (!mysql_num_rows())
   return SendNSMessage(playerid, COLOR_RED, "The password you supplied is invalid.");

  new index, line[256];

  mysql_fetch_row_format(line, "|");

  PlayerInfo[playerid][LoggedIn] = true;
  PlayerInfo[playerid][UserID] = strval(strtok(line, index, '|'));
  PlayerInfo[playerid][Level] = strval(strtok(line, index, '|'));
  PlayerInfo[playerid][Kills] = strval(strtok(line, index, '|'));

  //some queries here

  mysql_free_result();
Can someone explain to me what
Код:
mysql_fetch_row_format()
exactly does? And what is the purpose of strtok here? I searched strtok on wiki, but its very poorly explained as in what exactly everything is doing. Can't find any explanation of that index parameter. I'm not someone who wants to copy stuff from other scripts. I want to grasp and understand what is going on in the code..

Thanks.
Reply


Messages In This Thread
[SOLVED] Storing variables from MySQL - by Faraday - 08.01.2010, 09:05
Re: [HELP] Storing variables from MySQL - by Faraday - 08.01.2010, 10:49
Re: [HELP] Storing variables from MySQL - by Programie - 08.01.2010, 12:25
Re: [HELP] Storing variables from MySQL - by Faraday - 08.01.2010, 13:09
Re: [HELP] Storing variables from MySQL - by Programie - 08.01.2010, 13:17
Re: [HELP] Storing variables from MySQL - by Faraday - 08.01.2010, 14:31

Forum Jump:


Users browsing this thread: 1 Guest(s)