FlyingSpoon Posted June 6, 2017 Share Posted June 6, 2017 (edited) download = false function downloadAvatar(uName,player) download = true if download == true then outputDebugString("[Profile] Fetching profile of - "..uName..".") local connection = dbConnect('mysql', 'dbname='..databaseINFO.db..';host='..databaseINFO.host, databaseINFO.user, databaseINFO.pass) local query = dbQuery(connection, "SELECT `avatar`, `uid` FROM `mybb_users` WHERE `username` = ?", uName); local result = dbPoll(query, -1); if(result and #result >= 1) then if (query == nil or false) then return false end dbFree(query); end end end addEvent("download",true) addEventHandler("download",root,download) [11:12:55] WARNING: download/server.lua:22: Bad usage @ 'dbConnect ' User database already has more than 'max_user_connections' active conn ections] Keeps giving me that error, and then stops/crashes the server. Edited June 6, 2017 by raysmta Link to comment
3aGl3 Posted June 6, 2017 Share Posted June 6, 2017 You should establish a database connection when the resource starts and use that for all the queries. Link to comment
FlyingSpoon Posted June 6, 2017 Author Share Posted June 6, 2017 Thanks, worked like charm - I did something like - details = { user = "" pass = "" db = "" } function connect() -- connected it here if connect then outputDebugString("Worked") else outputDebugString("Didn't work") end end addEventHandler("onResourceStart", root, connect) -- then called in my other function 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