Sign in to follow this  
tommymaster

I want a mysql value but i get userdata!

Recommended Posts

Hi. I want to protect my server from incompetent launches, so i am trying to make a system, whenever the server starts it asks for a 128 character password what is inserted to my database.
But i have a little problem.

This is the script i have made so far:
I just want to debug, if it can poll the password from the database, but the outputChatBox displays a userdata.

SERV_LAUNCH_PW = exports.db:sqlQuery("SELECT server_launch_pw FROM server_vars")

local result = dbPoll (SERV_LAUNCH_PW, -1)
	if #result > 0 then
		outputChatBox (tostring(result))
end
function sqlQuery(query, ...)
	return dbQuery(connection, query, ...)
end

My SQL script is here too. Also, i have an other question. Is there a way, i don't have to add the dbPoll and #result line each time i make a SELECT query from mysql, and put it into the mysql script instead?

Share this post


Link to post

In order to poll the password you have to do it this way:

SERV_LAUNCH_PW = exports.db:sqlQuery("SELECT server_launch_pw FROM server_vars")

local result = dbPoll (SERV_LAUNCH_PW, -1)
if #result > 0 then
  local password = SERV_LAUNCH_PW[1].server_launch_pw;
  outputChatBox(password)
end

for the dbPoll, you can try this:

-- use the database connection variable in (connection).

function _Query (...)
	if connection then
		local queryS = dbQuery(connection, ... )
		local result = dbPoll(queryS,-1)
		return result 
	else
		return false
	end
end

-- Usage:
local SERV_LAUNCH_PW = _Query ('SELECT server_launch_pw FROM server_vars')
  if ( #SERV_LAUNCH_PW > 0 ) then
  	local password = SERV_LAUNCH_PW[1].server_launch_pw;
  	outputChatBox(password)
  end

 

  • Thanks 1

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.