Jump to content

SQLite syntax error


xyzii

Recommended Posts

Posted

Hello, I have a problem with my vehicle system and logging systems that are based on account names.

So when someone registers an account that has symbols like @, - etc in it, the databases give syntax errors

  • 3 weeks later...
Posted

con:exec("CREATE TABLE IF NOT EXISTS ´"..player.account.name.."´ ('num', 'veh', 'x', 'y', 'z', 'rot', 'bp', 'ups', 'plate', 'hp', 'fuel', 'lock', 'r', 'g', 'b', 'r2', 'g2', 'b2', 'paintjob')")

Posted

i think correct syntax of SQL creating table is like this

local connection = dbConnect("sqlite", "test.db")
dbExec(connection,"CREATE TABLE IF NOT EXISTS table(numberone TEXT, numbertwo TEXT)")

 

Posted
17 hours ago, xyzii said:

con:exec("CREATE TABLE IF NOT EXISTS ´"..player.account.name.."´ ('num', 'veh', 'x', 'y', 'z', 'rot', 'bp', 'ups', 'plate', 'hp', 'fuel', 'lock', 'r', 'g', 'b', 'r2', 'g2', 'b2', 'paintjob')")

The entire way you do it is the error. You shouldn't create a new table for every player that registers...
Also you should never use .. to create SQL querys...like this your database is very open to SQL injections.

The proper way to do it would be a table with vehicles and a column with the account name to identify the vehicle owner.

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...