Jump to content

[HELP] MTA-MySQL Question


Recommended Posts

In php i have done this code:

$sql="SELECT * FROM user_table WHERE username='$user' and password='$pass'";

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

http://wiki.mtasa.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

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