Jump to content

Blank fields, mySQL


Lloyd Logan

Recommended Posts

Why is this creating an account row and password row, but its putting in blank values e.g. accounts || Password

both just equal blank!

CLIENT

function checkRegField() 
    local inputusernamereg = guiGetText(GUIEditor.edituserreg) 
    local inputpasswordreg = guiGetText(GUIEditor.editpassreg) 
       triggerServerEvent("submitRegister", localPlayer, inputusernamereg, inputpasswordreg) 
end 

SERVER

function submitReg() 
    dbExec(server, "CREATE TABLE IF NOT EXISTS accounts (accountname TEXT NOT NULL, password TEXT NOT NULL)") 
    new = dbExec(server, "INSERT INTO accounts (accountname, password) VALUES (?,?)", inputusernamereg, inputpasswordreg) 
    output = outputChatBox("You have successfully created an account!") 
    triggerClientEvent("closedok", getRootElement()) 
    triggerClientEvent("onclose", getRootElement()) 
end 

Link to comment
function submitReg() 
    dbExec(server, "CREATE TABLE IF NOT EXISTS accounts (accountname TEXT NOT NULL, password TEXT NOT NULL)") 
    new = dbExec(server, "INSERT INTO accounts (accountname, password) VALUES ('"..inputusernamereg.."','"..inputpasswordreg.."')") 
    output = outputChatBox("You have successfully created an account!") 
    triggerClientEvent("closedok", getRootElement()) 
    triggerClientEvent("onclose", getRootElement()) 
end 

Link to comment

Try this:

dbExec(server, "CREATE TABLE IF NOT EXISTS accounts (accountname TEXT, password TEXT)") 
function submitReg( inputusernamereg, inputpasswordreg ) 
    dbExec(server, "INSERT INTO accounts (accountname, password) VALUES (?,?)", tostring ( inputusernamereg ), tostring ( inputpasswordreg ) ) 
    outputChatBox("You have successfully created an account!", source) 
    triggerClientEvent(source, "closedok", source ) 
    triggerClientEvent(source, "onclose", source ) 
end 

If it doesn't work, post your database connection.

function submitReg() 
    dbExec(server, "CREATE TABLE IF NOT EXISTS accounts (accountname TEXT NOT NULL, password TEXT NOT NULL)") 
    new = dbExec(server, "INSERT INTO accounts (accountname, password) VALUES ('"..inputusernamereg.."','"..inputpasswordreg.."')") 
    output = outputChatBox("You have successfully created an account!") 
    triggerClientEvent("closedok", getRootElement()) 
    triggerClientEvent("onclose", getRootElement()) 
end 

When you're using database functions, it's better to use "VALUES ( ?, ?, ... )"

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