MedKhiti Posted April 30, 2014 Share Posted April 30, 2014 - - Connection functions local connection = nil local function connect( ) connection = dbConnect( "mysql", "dbname=mtadev;host=127.0.0.1;port=3306;unix_socket=/var/run/mysqld/mysqld.sock", "mtadev", "t9CPZJbJTe8FtnwC", "share=1" ) if connection then outputConsole ( "Server is now connected with the MySQL database!", 1 ) return true else outputConsole ( "Connection with the MySQL database failed!", 1 ) return false end end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), connect ) -- Exported functions function query( ... ) if connection then local qh = dbQuery( connection, ... ) local result = dbPoll( qh, -1 ) return result else return false end end -- Get a single row from the database function querySingle( str, ... ) if connection then local result = query( str, ... ) if type(result) == 'table' then return result[1] end return result else return false end end -- DB exec as used function exec( str, ... ) if connection then local qh = dbExec( connection, str, ... ) return qh else return false end end i want help please i want to connect to data base h whats The soloution for local server i mean not hosted help please Meta XML <meta> <info author="1337" version="1.0.0" type="script" name="1337mysql" description="MySQL config resource" /> <script src="mysql.lua"/> <!-- The Exports --> <export function="query"/> <export function="querySingle"/> <export function="exec"/> <export function="free"/> </meta> Link to comment
xXMADEXx Posted April 30, 2014 Share Posted April 30, 2014 Change the host to localhost, and you need to be running an MySQl server if you don't have one. Link to comment
Dealman Posted May 1, 2014 Share Posted May 1, 2014 And you have a MySQL server running locally? Link to comment
Martyz Posted May 1, 2014 Share Posted May 1, 2014 change "mtadev" to "root" and"t9CPZJbJTe8FtnwC" to "" (if you have no pass) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now