Jump to content

Login MySQL Problem


FlyingSpoon

Recommended Posts

-- Default 
host = "127.0.0.1" -- Database Host 
username = "root" -- Database Username 
password = "" -- Database Password 
db = "mvp_forum" -- Database ( Where you got your tables ) 
  
handler = mysql_connect( host, username, password, db ) 
  
  
function onLogin ( strInfoUser, strInfoPass ) 
    handler = mysql_connect( host, username, password, db ) 
    local login = mysql_query(handler,"SELECT * FROM mvp_forum WHERE name = '"..mysql_escape_string( handler, strInfoUser ).."' AND members_pass_hash = '"..mysql_escape_string( handler, md5(strInfoPass) ).."';") 
    if login then 
        local rows = mysql_num_rows(login) 
        if rows == 1 then 
            triggerClientEvent( player, "HideLogin", getRootElement() ) 
            outputChatBox("* You successfully logged in your account!", player, 255, 255, 255) 
            spawnPlayer( player, 0,0,3 )  
            fadeCamera( player, true ) 
            setCameraTarget( player, player ) 
        else 
            outputChatBox("* Login failed!", player, 255, 255, 255) 
        end 
        mysql_free_result(login) 
    end 
end 
addEvent( "onRequestAccessTo", true ) 
addEventHandler( "onRequestAccessTo", getRootElement(), onLogin ) 

[2015-12-19 19:10:17] ERROR: Line 12 -  bad argument #2 to 'mysql_escape_string' (string expected, got nil) 

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