Jump to content

Database connect problem


Recommended Posts

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

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...