FlyingSpoon Posted December 19, 2015 Share Posted December 19, 2015 -- 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
Addlibs Posted December 20, 2015 Share Posted December 20, 2015 1) mysql_escape_string needs the connection handler as first argument, the string-to-escape goes second 2) It's better to use db* functions in my opinion. Link to comment
FlyingSpoon Posted December 20, 2015 Author Share Posted December 20, 2015 Well, I am still a MySQL learner, I am trying to connect this login panel to my Forums, I am really confused at the moment Link to comment
Noki Posted December 20, 2015 Share Posted December 20, 2015 The in-built db functions pass input as parameters, as opposed to processing input. That means you don't need to worry about SQL injection. 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