21.12.2017, 19:31
https://sampwiki.blast.hk/wiki/MySQL#mysql_connect
You should define at the top of your script your mysql credentials
You'll have to change these credentials to your mysql database's ones
This is needed to store the mysql handle. you need it to use mysql_tquery and etc..
After that you simply use mysql_connect function
Here we get the mysql handle and put it inside database variable
You should define at the top of your script your mysql credentials
pawn Код:
#define MYSQL_HOST "127.0.0.1c
#define MYSQL_USERNAME "root"
#define MYSQL_PASSWORD "password"
#define MYSQL_DATABASE "yourdatabase"
new MySQL:database;
public OnGamemodeModeInit()
{
database = mysql_connect(MYSQL_HOST, MYSQL_USERNAME, MYSQL_PASSWORD, MYSQL_DATABASE);
return 1;
}
pawn Код:
new MySQL:database;
After that you simply use mysql_connect function
pawn Код:
database = mysql_connect(MYSQL_HOST, MYSQL_USERNAME, MYSQL_PASSWORD, MYSQL_DATABASE);