SlashBuster

Mysql select

Recommended Posts

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) 

Share this post


Link to post

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) 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.