Jump to content

A problem with exporting mySQL connection


jingzhi

Recommended Posts

Hello,

I have a problem with exporting the mySQL connection into the login script, the error is: "failed to call 'mySQL:dbConnection' [string'?']"

Here are the codes

mySQL.lua

local dbType="mysql" 
local dbName="mta" 
local dbHost="127.0.0.1" 
local dbUsername="jingzhi" 
local dbPassword="" 
local dbConnection = dbConnect(dbType,"dbname="..dbName..";"..dbHost.."",dbUsername,dbPassword) 
  
if dbConnection then 
    outputDebugString("MySQL has been successfuly connected!") 
else 
    outputDebugString("Failed to connect to MySQL!") 
end 
  
function dbConnection() 
    return dbConnection 
end 
  

meta.xml

    "JingZhi" type="script" /> 
    

login.lua

local dbConnection = exports["mySQL"]:dbConnection() 

Link to comment
Hello,

I have a problem with exporting the mySQL connection into the login script, the error is: "failed to call 'mySQL:dbConnection' [string'?']"

Here are the codes

mySQL.lua

local dbType="mysql" 
local dbName="mta" 
local dbHost="127.0.0.1" 
local dbUsername="jingzhi" 
local dbPassword="" 
local dbConnection = dbConnect(dbType,"dbname="..dbName..";"..dbHost.."",dbUsername,dbPassword) 
  
if dbConnection then 
    outputDebugString("MySQL has been successfuly connected!") 
else 
    outputDebugString("Failed to connect to MySQL!") 
end 
  
function dbConnection() 
    return dbConnection 
end 
  

meta.xml

    "JingZhi" type="script" /> 
    

login.lua

local dbConnection = exports["mySQL"]:dbConnection() 

C'mon guys! need help!

Link to comment

You forgot to put host= ...

local dbType="mysql" 
local dbName="mta" 
local dbHost="127.0.0.1" 
local dbUsername="jingzhi" 
local dbPassword="" 
local dbConnection = dbConnect(dbType,"dbname="..dbName..";host="..dbHost.."",dbUsername,dbPassword) 
  
if dbConnection then 
    outputDebugString("MySQL has been successfuly connected!") 
else 
    outputDebugString("Failed to connect to MySQL!") 
end 
  
function dbConnection() 
    return dbConnection 
end 

Link to comment
You forgot to put host= ...
local dbType="mysql" 
local dbName="mta" 
local dbHost="127.0.0.1" 
local dbUsername="jingzhi" 
local dbPassword="" 
local dbConnection = dbConnect(dbType,"dbname="..dbName..";host="..dbHost.."",dbUsername,dbPassword) 
  
if dbConnection then 
    outputDebugString("MySQL has been successfuly connected!") 
else 
    outputDebugString("Failed to connect to MySQL!") 
end 
  
function dbConnection() 
    return dbConnection 
end 

dbConnect(dbType,"dbname="..dbName..";host="..dbHost.."",dbUsername,dbPassword) 

I think I put....

Link to comment
Hello,

I have a problem with exporting the mySQL connection into the login script, the error is: "failed to call 'mySQL:dbConnection' [string'?']"

Here are the codes

mySQL.lua

local dbType="mysql" 
local dbName="mta" 
local dbHost="127.0.0.1" 
local dbUsername="jingzhi" 
local dbPassword="" 
local dbConnection = dbConnect(dbType,"dbname="..dbName..";"..dbHost.."",dbUsername,dbPassword) 
 Need help! 
if dbConnection then 
    outputDebugString("MySQL has been successfuly connected!") 
else 
    outputDebugString("Failed to connect to MySQL!") 
end 
  
function dbConnection() 
    return dbConnection 
end 
  

meta.xml

    "JingZhi" type="script" /> 
    

login.lua

local dbConnection = exports["mySQL"]:dbConnection() 

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...