sahwel Posted May 8, 2018 Share Posted May 8, 2018 Hello guyz. I have the following problem: I have an mta:sa server, and I'm trying to connect it to mysql, but it doesn't work. It finds the table, but the table has records in it, which cannot be found. Link to comment
myonlake Posted May 8, 2018 Share Posted May 8, 2018 (edited) Maybe the user you used to connect doesn't have SELECT privileges. Edited May 8, 2018 by myonlake Link to comment
sahwel Posted May 8, 2018 Author Share Posted May 8, 2018 how/where can i add privileges to an account Link to comment
Dimos7 Posted May 9, 2018 Share Posted May 9, 2018 For get records from database you need dbQuery dbPoll Link to comment
sahwel Posted May 9, 2018 Author Share Posted May 9, 2018 Guys this is the full script and the playerName, playerPassword, ID and the PlayerMoney are nil, what should I need to do? local host = "hotstname..." local username = "username..." local password = "password..." local db = "db_name" local results = {} local connection = dbConnect("mysql","dbname=dbname;host=hostname", username, password, "autoreconnect=1") local qh = dbQuery(connection, "SELECT * FROM `asd` WHERE `ID` = ?", 1) local row = dbPoll(qh, -1) if (row) then for k, row in ipairs (row) do local id = tonumber(row["ID"]) local playerName = tostring(row["PlayerName"]) local playerPassword = tostring(row["PlayerPassword"]) local PlayerMoney = tonumber(row["PlayerMoney"]) end end Link to comment
myonlake Posted May 9, 2018 Share Posted May 9, 2018 You don't seem to be using the right database details in your snippet. local host = "hotstname..." local username = "username..." local password = "password..." local db = "db_name" local connection = dbConnect("mysql", "dbname=" .. db .. ";host=" .. host, username, password) if (connection) then local qh = dbQuery(connection, "SELECT * FROM `asd` WHERE `ID` = ?", 1) if (qh) then local result = dbPoll(qh, -1) if (result) then for _, row in ipairs(result) do local id = tonumber(row["ID"]) local playerName = tostring(row["PlayerName"]) local playerPassword = tostring(row["PlayerPassword"]) local PlayerMoney = tonumber(row["PlayerMoney"]) end end end end Link to comment
myonlake Posted May 9, 2018 Share Posted May 9, 2018 1 hour ago, sahwel said: Thank you so much You're welcome! 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