tjeaton Posted March 24, 2010 Share Posted March 24, 2010 In php i have done this code: $sql="SELECT * FROM user_table WHERE username='$user' and password='$pass'"; $result=mysql_query($sql); Would it look like this in mta scripting: local user = "tom" local pass = "pass" local result = mysql_query(connectionhandler, "SELECT * FROM user_table WHERE username='user' and password='pass') If anyone can confirm or help me on this, i would benefit from this alot. Link to comment
dzek (varez) Posted March 24, 2010 Share Posted March 24, 2010 IMPORTANT: It is strongly recommended to call mysql_free_result after a query,specially if it returns some data. Query results can be automatically deleted by the lua garbage collector, so if you forget to free a result it will be freed at some time in the future, but it doesn't know the real result data size in memory so it can delay the memory destroying more than it should. Read more about mysql_query on wiki: https://wiki.multitheftauto.com/wiki/Modules/MTA- ... ysql_query local user = "tom" local pass = "pass" -- you need to escape all data given by players, read about SQL Injection on google user = mysql_escape_string(connectionhandler, user) pass = mysql_escape_string(connectionhandler, pass) local result = mysql_query(connectionhandler, "SELECT * FROM user_table WHERE username='"..user.."' and password='"..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