format(query, sizeof(query), "INSERT INTO ekwipunek (`slot1nazwa`, `slot1wartosc`,`nick`) VALUES ('%s', '%d',`%s`)",brak, 0, PlayerName(playerid)); mysql_tquery(SQL_ID,query); format(query, sizeof(query), "INSERT INTO bank (`uid`, `stan`, `nick`) VALUES (`%i`,`%i`,`%s`)", pDane[playerid][UID],pDane[playerid][wBank],PlayerName(playerid)); mysql_query(SQL_ID,query);
Hello, I have a problem because I wanted to create tables 'bank' means I created it in phpmyadmin, I gave the appropriate values INT, TEXT, uid, state, nickname% i,% i,% s, but unfortunately in phpmyadmin nothing adds, does not complete the table.
so create data for the player's table after registration Код HTML:
format(query, sizeof(query), "INSERT INTO ekwipunek (`slot1nazwa`, `slot1wartosc`,`nick`) VALUES ('%s', '%d',`%s`)",brak, 0, PlayerName(playerid)); mysql_tquery(SQL_ID,query); format(query, sizeof(query), "INSERT INTO bank (`uid`, `stan`, `nick`) VALUES (`%i`,`%i`,`%s`)", pDane[playerid][UID],pDane[playerid][wBank],PlayerName(playerid)); mysql_query(SQL_ID,query); |
public OnGameModeInit()
{
//exemple to MySQL R41-4
SQL_ID = mysql_connect(...); // connection to the database
new Cache:result = mysql_query(SQL_ID,"CREATE TABLE IF NOT EXISTS `ekwipunek`(`slot1nazwa` varbinary(30) NOT NULL,`slot1wartosc` int(10) NOT NULL,`slot1nazwa` varbinary(30) NOT NULL) ENGINE = InnoDB CHARACTER SET=utf8");
cache_delete(result);
new Cache:result1 = mysql_query(SQL_ID,"CREATE TABLE IF NOT EXISTS `bank`(`uid` int(10) NOT NULL,`stan` int(10) NOT NULL,`nick` varbinary(24) NOT NULL) ENGINE = InnoDB CHARACTER SET=utf8");
cache_delete(result1);
return true;
}
new query[200];
format(query, sizeof(query), "INSERT INTO ekwipunek (`slot1nazwa`, `slot1wartosc`,`nick`) VALUES ('%e', '%d','%e')",brak, 0, PlayerName(playerid)); //add %e is string escape
mysql_tquery(SQL_ID,query);
new query[200];
format(query, sizeof(query), "INSERT INTO bank (`uid`, `stan`, `nick`) VALUES ('%i','%i','%e')", pDane[playerid][UID],pDane[playerid][wBank],PlayerName(playerid));//add %e is string escape
mysql_query(SQL_ID,query);
[10:54:28] [plugins/mysql] error #1064 while executing query "CREATE TABLE IF NOT EXISTS `ekwipunek`(`slot1nazwa` varbinary(30) NOT NULL,`slot1wartosc` int(10) NOT NULL,`slot1nazwa` nick(24) NOT NULL,) ENGINE = InnoDB CHARACTER SET=utf8": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'nick(24) NOT NULL,) ENGINE = InnoDB CHARACTER SET=utf8' at line 1
[10:54:28] [plugins/mysql] cache_delete: invalid cache id '0'
[10:55:02] [plugins/mysql] error #1054 while executing query "INSERT INTO bank (`uid`, `stan`, `nick`) VALUES (`0`,`0`,`RiP_eaK`)": Unknown column '0' in 'field list'
[10:55:02] [plugins/mysql] error #1146 while executing query "INSERT INTO ekwipunek (`slot1nazwa`, `slot1wartosc`,`nick`) VALUES ('', '0',`RiP_eaK`)": Table 'bazagm.ekwipunek' doesn't exist
PHP код:
|
public OnGameModeInit()
{
//exemple to MySQL R41-4
SQL_ID = mysql_connect(...); // connection to the database
new Cache:result = mysql_query(SQL_ID,"CREATE TABLE IF NOT EXISTS `ekwipunek`(`slot1nazwa` varbinary(30) NOT NULL,`slot1wartosc` int(10) NOT NULL,`slot1nazwa` varbinary(30) NOT NULL) ENGINE = InnoDB CHARACTER SET=utf8");
cache_delete(result);
new Cache:result1 = mysql_query(SQL_ID,"CREATE TABLE IF NOT EXISTS `bank`(`uid` int(10) NOT NULL,`stan` int(10) NOT NULL,`nick` varbinary(24) NOT NULL) ENGINE = InnoDB CHARACTER SET=utf8");
cache_delete(result1);
return true;
}
mysql r41-4, the table does not create any more, but I create it manually and it does not fill data, values, nickname does not exist after registering an account, it does not add to the table
|
//maybe it's the connection problem.
public OnGameModeInit()
{
//exemple to MySQL R41-4
SQL_ID = mysql_connect(...); // connection to the database
if(mysql_errno() != 0) { // check in server_log.txt connected base or no.
print("MySQL not connected!");
}else print("MySQL connected!");
return true;
}
new query[200];
format(query, sizeof(query), "INSERT INTO ekwipunek (`slot1nazwa`, `slot1wartosc`,`nick`) VALUES ('%e', '%d','%e')",brak, 0, PlayerName(playerid)); //add %e is string escape
mysql_tquery(SQL_ID,query);
new query[200];
format(query, sizeof(query), "INSERT INTO bank (`uid`, `stan`, `nick`) VALUES ('%i','%i','%e')", pDane[playerid][UID],pDane[playerid][wBank],PlayerName(playerid));//add %e is string escape
mysql_query(SQL_ID,query);
mysql_format(/* Your Query Inside */)
mysql_tquery
mysql_format(query, sizeof query, "CREATE TABLE IF NOT EXISTS `accounts` (id int(11) NOT NULL)");
myqsl_tquery(database, query);