Jump to content

in what event


sconer

Recommended Posts

Hello, i want to connect to mysql in my server. But i don't know what eventhandler i need to call to connect to the mysql. Who knows please reply to this thread. Thanks.

function mysqlconnect() 
  
    handler = mysql_connect("localhost", "root", "", "crpmta") -- Establish the connection 
    if ( not handler ) then -- The connection failed 
      outputDebugString("Unable to connect to the MySQL server") 
    else 
      mysql_close(handler) -- Close the connection 
    end 
  
end 

Link to comment

If you want it to connect to the MySQL server when the resource starts, then you can use onResourceStart.

function mysqlconnect ( ) 
    handler = mysql_connect ( "localhost", "root", "", "crpmta" ) -- Establish the connection 
    if ( not handler ) then -- The connection failed 
        outputDebugString ( "Unable to connect to the MySQL server" ) 
    else 
        mysql_close ( handler ) -- Close the connection 
    end 
end 
addEventHandler ( "onResourceStart", resourceRoot, mysqlconnect ) 

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