Forum

> > CS2D > Scripts > LuaSQL errors
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch LuaSQL errors

9 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt LuaSQL errors

Marcell
Super User Off Offline

Zitieren
Welcome i post it to here, because its about cs2d. So please do not say i did something wrong with this, because no..

So i installed LuaSQL to cs2d well, and now i trying to make some tables, etc.. but somewhy i got error..
i hope someone, who know MySQL could help..

CODE:
Spoiler >


× Error is:
LUA ERROR: sys/lua/mysql.lua:9: LuaSQL: Error executing query. MySQL: You have a
n error in your SQL syntax; check the manual that corresponds to your MySQL serv
er version for the right syntax to use near 'UNSIGNED,
age TINYINT UNSIGNED,
email VARCHAR(64),
usgn INT,
money INT,
cou' at line 3

alt Re: LuaSQL errors

Apache uwu
User Off Offline

Zitieren
VARCHAR is a type of string, UNSIGNED deals with the signs of numbers, also you missed a comma separating the declaration of PRIMARY KEY.

Fixed:

1
2
3
4
5
6
7
8
9
10
11
12
CREATE TABLE users(
     id INT UNSIGNED NOT NULL AUTO_INCREMENT,
     name VARCHAR(64),
     age TINYINT UNSIGNED,
     email VARCHAR(64),
     usgn INT,
     money INT,
     country VARCHAR(64),
     isadmin BIT(1),
     admin_lvl TINYINT UNSIGNED,
     PRIMARY KEY (id)
)

alt Re: LuaSQL errors

Marcell
Super User Off Offline

Zitieren
new error

LUA ERROR: sys/lua/mysql.lua:31: bad argument #5 to 'format' (string expected, got nil)

alt Re: LuaSQL errors

gotya2
GAME BANNED Off Offline

Zitieren
msg2(string.format (id, "©255000000 Name: %s, USGN: %s, Money: %s", row.name, row.usgn, row.money))

--->

msg2(id,string.format(..))

alt Re: LuaSQL errors

Apache uwu
User Off Offline

Zitieren
Check out that section:

1
2
3
4
res = assert (con:execute(string.format([[
    INSERT INTO users
    VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')]], p.name, p.age, p.email, p.usgn, p.money, p.country, p.isadmin, p.adminlvl)
  ))

You need eight values within the query, because you are passing eight properties of `p`.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht