Search the Community
Showing results for tags 'query'.
-
The connection is okay but dbQuery and dbPoll first argument got nil. ( sorry for my bad english ) ERROR: MYSQL CONNECTION CODE: "felhasznalo" SCRIPT:
- 9 replies
-
- mta
- connection
-
(and 7 more)
Tagged with:
-
Hello guys!How can i use the variables bannedBy, and accountID outside of this code block? local bannedBy local accountID for _, row in ipairs(query) local bannedBy = row["bannedBy"] local accountID = row["accountID"] end
- 4 replies
-
- dbquery
- for statement
-
(and 2 more)
Tagged with:
-
Hi guys, I'm trying to make a execute query function, this is what I got. But I seem to be doing something wrong. Server sided addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() connection = dbConnect(dbInfo["databaseType"], "dbname="..dbInfo["dbname"]..";host="..dbInfo["host"], dbInfo["username"], dbInfo[password]) if connection then outputDebugString("Connection with database was successfully established.") else outputDebugString("Connection with database couldn't be established.") end end) function execQuery (queryString) local query = dbQuery(connection, tostring(queryString)) if (string.find(queryString, "SELECT")) then local result = dbPoll(query, -1 ) if not result == nil then return result end end dbFree(query) end This I have server sided in another file for testing my db addEventHandler ("onPlayerJoin", getRootElement(), function () local query = execQuery("SELECT username FROM users WHERE username = '"..getPlayerName(source) .."'") if (query) then outputChatBox("found username: "..tostring(query[0])) else outputChatBox("didn't found username, inserting!") execQuery("INSERT INTO users VALUES('', '"..getPlayerName(source).."')") end end ) Also I'm not quite sure how to get the value since I'm returning a table atm. Kind regards P.S. my database looks like this