Jump to content

Mysql select


Recommended Posts

Posted

So now I'm quiet close to finish my login/ register script but 1 more problem is there the server is saying that there is an error in line 6 but I think it is right

StartServer.lua:6: ')' expected near ',' 

function loginHandler(username,password) 
     
     local = connect = dbConnect("mysql", "dbname=mta_userdata;host=127.0.0.1","root","klaas","share=1" ) 
     
    if 
    (connect,"SELECT (Name,Passwort) FROM  `user` WHERE (Name = ?,Passwort = ?)", tostring ( username ), tostring ( password ) ) 
    then 
     
     
            spawnPlayer(source, 1959.55, -1714.46, 10) 
            fadeCamera(source, true) 
            setCameraTarget(source, source) 
            outputChatBox("Willkommen!", source) 
    end 
     
    else 
        outputChatBox("Invalid username and password. Please re-connect and try again.",source) 
    end 
end 
addEvent("submitLogin", true) 
addEventHandler("submitLogin",getRootElement(),loginHandler) 

Posted

Try this, your script is a mess anyways so I am not assuming this would work anyways.

function loginHandler(username, password) 
    local = connect = dbConnect("mysql", "dbname=mta_userdata;host=127.0.0.1", "root", "klaas", "share=1") 
    if connect then 
        local query = dbQuery(connect, "SELECT Name, Passwort FROM `user` WHERE Name = `" .. username .. "`, Passwort = `" .. password .. "`") 
        if query then 
            spawnPlayer(source, 1959.55, -1714.46, 10) 
            fadeCamera(source, true) 
            setCameraTarget(source, source) 
            outputChatBox("Willkommen!", source, 0, 255, 0, false) 
        else 
            outputChatBox("Invalid username and password. Please reconnect and try again.", source, 255, 0, 0, false) 
        end 
        dbFree(query) 
    end 
end 
addEvent("submitLogin", true) 
addEventHandler("submitLogin", root, loginHandler) 

If I helped you, please click the like button on the right ;) Thanks!

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