Forum

> > CS2D > Scripts > LuaSQL errors
Forums overviewCS2D overview Scripts overviewLog in to reply

English LuaSQL errors

9 replies
To the start Previous 1 Next To the start

old LuaSQL errors

Marcell
Super User Off Offline

Quote
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

old Re: LuaSQL errors

Apache uwu
User Off Offline

Quote
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)
)

old Re: LuaSQL errors

Marcell
Super User Off Offline

Quote
new error

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

old Re: LuaSQL errors

gotya2
GAME BANNED Off Offline

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

--->

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

old Re: LuaSQL errors

Apache uwu
User Off Offline

Quote
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`.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview