15.06.2015, 17:25
Hello folks!
I just started to learn SAMP coding and trying to build modular system instead off massive one file but there is the issue.
file: main.pwn
file: mysql.pwn
The issue is that invalid connection handle (id: 0).
Questions:
1. How i can connect to mysql once and use it across all includes to make queries?
2. How to get it work as include in example above?
Thank you in advance.
I just started to learn SAMP coding and trying to build modular system instead off massive one file but there is the issue.
file: main.pwn
Код:
#include <a_samp>
#include <a_mysql>
#include "../include/mysql.pwn"
new mysql;
main(){
}
OnGameModeInit() {
mysql = Mysql_Initi();
return 1;
}
Код:
#include <a_samp>
#include <a_mysql>
#define HOST "localhost"
#define USER "root"
#define DB "test"
#define PWD "12345"
Mysql_Initi() {
new mysql;
mysql = mysql_connect(HOST, USER, DB, PWD);
mysql_log(LOG_ERROR | LOG_WARNING | LOG_DEBUG);
if (mysql_errno(mysql) != 0) print("MySQL is broken");
return mysql;
}
Questions:
1. How i can connect to mysql once and use it across all includes to make queries?
2. How to get it work as include in example above?
Thank you in advance.


