Jump to content

[HELP] MTA-MySQL Question


tjeaton

Recommended Posts

Posted

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

Posted
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.."'")

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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