Zonex Favel Posted February 27, 2008 Share Posted February 27, 2008 My first question is does the database get completely written over when you create a new table, and do all the values get erased? I'm also having trouble with using the executeSQLQuery function. Table executeSQLCreateTable("Players","player_id TEXT, player_username TEXT, player_password TEXT") functions not working function registerPlayer(playerName, pass) [b]regSuccess = executeSQLQuery("INSERT INTO Players VALUES ('001',?,?)", playerName, pass)[/b] if(regSuccess) then outputChatBox("Registration Success") end [b]player = executeSQLQuery("SELECT player_password FROM Players WHERE player_username='gamemode'")[/b] end The first one gives me Error: Database query failed: unrecognized token: "\" then the first line.The second one gives me Error: Database query failed: near "symbols" syntax error then the second line.Thanks for the help in advance everyone Link to comment
Twig Posted February 27, 2008 Share Posted February 27, 2008 Use: http://development.mtasa.com/index.php? ... eSQLInsert & http://development.mtasa.com/index.php? ... eSQLSelect executeSQLQuery is screwed up, I've tried pointing it out but it's best just not to use it. Link to comment
Zonex Favel Posted February 28, 2008 Author Share Posted February 28, 2008 Thank you for your help. I was trying to avoid those because of SQL injection attacks but I should protect against those myself anyways. Link to comment
eAi Posted February 28, 2008 Share Posted February 28, 2008 Can you provide more information as to what is wrong with executeSQLQuery - a test case would be useful. Link to comment
Zonex Favel Posted February 28, 2008 Author Share Posted February 28, 2008 function makeTables() executeSQLCreateTable("locations", "location_name TEXT, location_pos TEXT") doInsertQ = executeSQLQuery("INSERT INTO locations VALUES ('origin', 'x=0y=0z=0')") if(doInsertQ) then outputConsole("insert Query successful") end doInsertE = executeSQLInsert("locations", "'origin', 'x=0y=0z=0'") if(doInsertE) then outputConsole("easy insert Query successful") end doSelectQ = executeSQLQuery("SELECT location_pos FROM locations WHERE location_name = 'origin'") if(doSelectQ) then outputConsole("select Query successful") end doSelectE = executeSQLSelect("locations", "location_pos", "location_name ='origin'") if(doSelectE) then outputConsole("easy select Query successful") end end addEventHandler( "onResourceStart", getResourceRootElement(getThisResource()),makeTables) I get these errors from the SQLQuery functions, the other two seem to work fine. They don't do an output message but they don't give me any errors. ERROR: Database query failed: near "X(symbol)": sytanx error (INSERT INTO locations VALUES ('origin', 'x=0y=0z=0')) ERROR: Database query failed: near "T": syntax error (SELECT location_pos FROM locations WHERE location_name = 'origin') Link to comment
Twig Posted February 29, 2008 Share Posted February 29, 2008 Those sounds almost identical to problems I had with it. As well as below: http://development.mtasa.com/index.php? ... teSQLQuery Link to comment
szlend Posted February 29, 2008 Share Posted February 29, 2008 I had similar problems too. ERROR: Database query failed: near "" It's funny because i didn't even have that symbol in my SQL command. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now