Jump to content

Получение данных MySQL


Recommended Posts

Беда, скрипт не может получить данные через dbQuery

function loginHandler(username,password) 
    --local DBuser, DBpass = GetAuth( username, password ) 
    local DBpass = 0 
    local DBuser = nil 
    outputChatBox("Начало запроса", client) 
    dbQuery (  
        function(qh) 
        -- результат в переменную result 
        outputChatBox("Получение данных", client) 
            local result, rows = dbPoll( qh, -1) 
            --если result имеет в себе что-то 
            if result then 
                outputChatBox("Выборка данных", client) 
                --считать колонки  
                --for _, row in ipairs ( result ) do 
                outputChatBox("Логин: " .. rows["Username"] .. " Пароль: " .. rows["Password"] .. "", client) 
                outputChatBox("Логин: " .. username .. " Пароль: " .. password .. "", client) 
                --outputChatBox ( rows["Username"] ) 
                --outputChatBox ( rows["Password"] ) 
                outputChatBox("Запись данных", client) 
                DBpass = rows["Password"] 
                DBuser = rows["Username"] 
                --end 
            end 
        end, 
    SQL, "SELECT * FROM accounts WHERE Username = ?, Password = ? ", username, password ) 
    -- проверяем username и password на правильность 
    if DBuser==username and DBpass==password then 
        -- игрок успешно залогинился, так что спавним его 
        if (client) then 
            spawnPlayer(client, 1766, -1912, 14.5, 270) 
            fadeCamera(client, true) 
            setCameraTarget(client, client) 
            outputChatBox("Добро пожаловать на сервер.", client) 
        end 
    else 
        -- если username или password неправильны, выводим игроку соответствующее сообщение 
        if client then 
            triggerClientEvent ( client, "AuthERROR", client, "Не верный Username или Password" ) 
            triggerClientEvent ( client, "AuthView", client ) 
        end 
    end          
end 

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