Hi all
I'm getting
[CODE]near "steamid": syntax error[/CODE]
with this query...
[CODE]
query = "CREATE TABLE shouts ( id int, PRIMARY KEY(id), steamid varchar(255), nick varchar(255), message varchar(255))"
doquery = sql.Query(query)
[/CODE]
What is wrong with it? :(
Try putting ` around the table name and the columns, so for example id would be `id`
[CODE]near "`steamid`": syntax error[/CODE]
I'm about ready to put my foot through garry's stupid wiki :suicide: Why does this not work? My syntax is taken basically verbatim from this guide [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexf158.html[/url] and it says all its code is tested working
Try
[code]
CREATE TABLE `shouts` ( `id` INT NOT NULL, `steamid` VARCHAR(255) NOT NULL, `nick` VARCHAR(255) NOT NULL, `message` VARCHAR(255) NOT NULL, PRIMARY KEY ( `id` ) )
[/code]
I get
[CODE]
column model is not unique
[/CODE]
Another part of my script is telling me the table exists, it uses this code to check
[CODE]if (sql.TableExists( "shouts" )) then
print("table exists")
end[/CODE]
So I don't know... is it making the table or not :S
You have to delete the old table first...
[QUOTE=EvacX;41746643]You have to delete the old table first...[/QUOTE]
I am dropping the table before I try... anyway I've got it working, thanks EvacX :)
this is my code
[CODE]
if (!sql.TableExists( "shouts" )) then
print("creating table...")
query = "CREATE TABLE `shouts` ( `id` INT NOT NULL, `shoutid` INT NOT NULL, `steamid` VARCHAR(255) NOT NULL, `nick` VARCHAR(255) NOT NULL, `message` VARCHAR(255) NOT NULL, PRIMARY KEY ( `id` ) )"
doquery = sql.Query(query)
if (sql.TableExists( "shouts" )) then
print("Table created successfully!")
else
print("table creation failed:" .. sql.LastError())
end
end
[/CODE]
Sorry, you need to Log In to post a reply to this thread.