Sql problem

Hi guys, I have a problem in general created a table and decided to make her anything but any attempt returned false, here’s an example of my code


sql.Query("CREATE TABLE IF NOT EXISTS autoulxz('id' INTEGER NOT NULL, 'idsteam' TEXT NOT NULL ,  'nickname' TEXT NOT NULL , 'time' TEXT NOT NULL, 'group' TEXT NOT NULL, PRIMARY KEY('id'));")

 sql.Query("INSERT INTO autoulxz (id, idsteam, nickname,time,group) VALUES(NULL, ".. sql.SQLStr(newuser:SteamID()) ..", ".. sql.SQLStr(newuser:Nick()) ..", ".. sql.SQLStr(args[2]) ..", ".. sql.SQLStr(args[3]) ..");")



Tell me what to do?

How about giving us the error it gives you

Nope nothing at all errors as if everything runs but nothing appears

print( sql.LastError() )

near “group”:syntax error

Which of the queries gave that error?

last which group


near "group": syntax error
near "group": syntax error
near "group": syntax error
near "group": syntax error

sql.Query("INSERT INTO autoulxz (id, idsteam, nickname,time,group) VALUES(NULL, ".. sql.SQLStr(newuser:SteamID()) ..", ".. sql.SQLStr(newuser:Nick()) ..", ".. sql.SQLStr(args[2]) ..", ".. sql.SQLStr(args[3]) ..");")

".. sql.SQLStr(args[3]) .."



I need you to give me the exact string of the query

[lua]local query = “INSERT INTO autoulxz (id, idsteam, nickname,time,group) VALUES(NULL, “… sql.SQLStr(newuser:SteamID()) …”, “… sql.SQLStr(newuser:Nick()) …”, “… sql.SQLStr(args[2]) …”, “… sql.SQLStr(args[3]) …”);”
print( query )[/lua]

Output:


INSERT INTO autoulxz (id, idsteam, nickname,time,group) VALUES(NULL, "STEAM_0:1:
19744995", "LostOne", "12", "superadmin");

Well first of all you’re inserting NULL into a ‘NOT NULL’ primary key field.
Second, you’re using double quotes instead of single quotes.

Right now, try

The problem remains




Code:_

sql.Query('INSERT INTO autoulxz (id, idsteam, nickname,time,group) VALUES('..newuser:UniqueID()..', '.. sql.SQLStr(newuser:SteamID()) ..', '.. sql.SQLStr(newuser:Nick()) ..', '.. sql.SQLStr(args[2]) ..', '.. sql.SQLStr(args[3]) ..');')

local query = 'INSERT INTO autoulxz (id, idsteam, nickname,time,group) VALUES('..newuser:UniqueID()..', '.. sql.SQLStr(newuser:SteamID()) ..', '.. sql.SQLStr(newuser:Nick()) ..', '.. sql.SQLStr(args[2]) ..', '.. sql.SQLStr(args[3]) ..');'
print( query )
print( sql.LastError() )


OutPut:

INSERT INTO autoulxz (id, idsteam, nickname,time,group) VALUES(3560436323, "STEA
M_0:1:19744995", "LostOne", "12", "superadmin");

near "group": syntax error


You changed the Lua quotes into single-quotes, that’s not what I meant.

The output


INSERT INTO autoulxz (id, idsteam, nickname,time,group) VALUES(3560436323, "STEA
M_0:1:19744995", "LostOne", "12", "superadmin");

Should be


INSERT INTO autoulxz (id, idsteam, nickname,time,group) VALUES(3560436323, 'STEA
M_0:1:19744995', 'LostOne', '12', 'superadmin')

I do not know how?

[lua]local search = { “\x00”, "
", “\r”, “\”, “’”, “\x1a” }
local replace = { “\\x00”, "
", “\r”, “\\”, “’’”, “\\x1a” }

function sql.Escape( str )

if not str then return "" end

for k, v in pairs( search ) do
	str = string.gsub( str, v, replace[k] )
end

return str

end

sql.Query( “CREATE TABLE IF NOT EXISTS autoulxz ( id INT NOT NULL PRIMARY KEY, idsteam VARCHAR(32) NOT NULL, nickname VARCHAR(64) NOT NULL, time VARCHAR(32) NOT NULL, group VARCHAR(64) NOT NULL )”)
sql.Query( “INSERT INTO autoulxz ( id, idsteam, nickname, time, group ) VALUES ( '” … newuser:UniqueID() … “’, '” … newuser:SteamID() … “’, '” … sql.Escape( newuser:Nick() ) … “’, '” … sql.Escape( args[2] ) … “’, '” … sql.Escape( args[3] ) … “’ )” )[/lua]

Try that

After that, other addons were screaming.


master/lua/sv_player_extension.lua:273
    3. fn - addons/pointshop-master/lua/sh_pointshop.lua:130
     4. unknown - addons/ulib/lua/ulib/shared/hook.lua:168


[ERROR] addons/pointshop-master/lua/sv_player_extension.lua:269: attempt to index field 'PS_Items' (a nil value)
  1. PS_HasItem - addons/pointshop-master/lua/sv_player_extension.lua:269
   2. PS_HasItemEquipped - addons/pointshop-

[editline]18th June 2013[/editline]


OutPut:
INSERT INTO autoulxz ( id, idsteam, nickname, time, group ) VALUES ( '3560436323', 'STEAM_0:1:19744995', 'LostOne', '12', 'superadmin' )
near "group": syntax error
П


[editline]18th June 2013[/editline]

a stop stop
this error


INSERT INTO autoulxq ( id, idsteam, nickname, time ) VALUES ( '3560436323', 'STEAM_0:1:19744995', 'LostOne', '12', 'superadmin' )
5 values for 4 columns
П