Does not create table data
#1

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);
Reply
#2

Quote:
Originally Posted by Eripe
Посмотреть сообщение
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);
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;
}
    new 
query[200];
    
format(querysizeof(query), "INSERT INTO ekwipunek (`slot1nazwa`, `slot1wartosc`,`nick`) VALUES ('%e', '%d','%e')",brak0PlayerName(playerid)); //add %e is string escape
    
mysql_tquery(SQL_ID,query);
    new 
query[200];
    
format(querysizeof(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); 
Reply
#3

PHP код:
[10:54:28] [plugins/mysqlerror #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/mysqlcache_deleteinvalid cache id '0'
[10:55:02] [plugins/mysqlerror #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/mysqlerror #1146 while executing query "INSERT INTO ekwipunek (`slot1nazwa`, `slot1wartosc`,`nick`) VALUES ('', '0',`RiP_eaK`)": Table 'bazagm.ekwipunek' doesn't exist 
Reply
#4

Quote:
Originally Posted by Eripe
Посмотреть сообщение
PHP код:
[10:54:28] [plugins/mysqlerror #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/mysqlcache_deleteinvalid cache id '0'
[10:55:02] [plugins/mysqlerror #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/mysqlerror #1146 while executing query "INSERT INTO ekwipunek (`slot1nazwa`, `slot1wartosc`,`nick`) VALUES ('', '0',`RiP_eaK`)": Table 'bazagm.ekwipunek' doesn't exist 
what version do you have in mysql? test now
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

Reply
#5

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
Reply
#6

Quote:
Originally Posted by Eripe
Посмотреть сообщение
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
PHP код:
//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;
 } 
Reply
#7

Next, after logging in, I have a data table ... MySQL_Init, and a link in ongamemodeinit if (MySQL_Init ())
{// code}
Reply
#8

I just explained how this works in a recent topic

PHP код:
    new query[200]; 
    
format(querysizeof(query), "INSERT INTO ekwipunek (`slot1nazwa`, `slot1wartosc`,`nick`) VALUES ('%e', '%d','%e')",brak0PlayerName(playerid)); //add %e is string escape 
    
mysql_tquery(SQL_ID,query); 
    new 
query[200]; 
    
format(querysizeof(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); 
Click me!

now it is possible to do CREATE in MYSQL 41-R2 although I had not tested it fully, and no I am not going to test it more since, it's a waste of time. Since creating a table happens only ones and it does not need to be repeated.

but in my opinion

PHP код:
mysql_format(/* Your Query Inside */)
mysql_tquery 
example
PHP код:
mysql_format(querysizeof query"CREATE TABLE IF NOT EXISTS `accounts` (id int(11) NOT NULL)");
myqsl_tquery(databasequery); 
something like this should work, I had made it work before on older versions but not on the latest ones
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)