mikeee324 Posted July 19, 2011 Share Posted July 19, 2011 I've been trying to make a register system that uses the mysql module from the wiki but this code i have always gives me an error. addEventHandler ( "onPlayerRegister", getRootElement(), function(username, password) local query = mysql_query(handler, "SELECT * FROM players WHERE username = "..username) if (mysql_num_rows(query) == 0) then mysql_query(handler, "INSERT INTO players (username, password) VALUES ('"..username.."',md5('"..password.."'))") else -- Account exists end mysql_free_result(query) end) the error is: bad argument #1 to 'mysql_num_rows' (mysqlResult expected, got nil) The table i'm querying is empty but that shouldn't affect what mysql_num_rows gets should it? Link to comment
Uisaqin Posted July 19, 2011 Share Posted July 19, 2011 local query = mysql_query(handler, "SELECT * FROM players WHERE username = '"..username.."'") also escape username and password variables with mysql_escape_string() before putting them into the query string so you are protected against sql injection Link to comment
mikeee324 Posted July 19, 2011 Author Share Posted July 19, 2011 yeah was going to that after i got it working which i have now (new to lua so the dots confuse me ) cheers 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