Jump to content

A problem with exporting mySQL connection


jingzhi

Recommended Posts

Posted

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() 

Posted
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!

Posted

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 

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

Posted
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() 

Posted

Well then update the code you post here (edit button). How could I know you made it right?

As alw7sh said post here if there are any errors from debugscript 3.

Posted
Well then update the code you post here (edit button). How could I know you made it right?

As alw7sh said post here if there are any errors from debugscript 3.

Thats all code

Posted
The script name is mySQL?

Also check the debug if there's any errors

Script name is mySQL and no error in debugscript 3 except for the one i showed there

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