Jump to content

[OK] Mysql DbExec Problem ! (null)


=KoG=Rouche

Recommended Posts

Hi all,

i got this problem when i try to create the entry in my DB.

DbExec failed; (1048) column "bMonth" could not be null. 

In the code bellow u can see that i initialize "bMonth" to 0 ...so what's wrong ? :-/

-- INSERT TO (Add an entity in player table) 
        local bDay,bMonth,bYear,level,VIP,achievementPoints,token,tokenBought = 0 
        local mail,welcomeText = "none" 
        dbExec(connect,"INSERT INTO Player (account,mail,bDay,bMonth,bYear,level,VIP,welcomeText,achivementPoints,token,tokenbought) VALUES (?,?,?,?,?,?,?,?,?,?,?)",account,mail,bDay,bMonth,bYear,level,VIP,welcomeText,achivementPoints,token,tokenbought) 
        outputDebugString("An entity in Player Table has been Created - OK") 
  

Thanks for your help.

=KoG=Rouche

Edited by Guest
Link to comment

Thanks it works now :-)

I've a new problem.

I try to check if the user is already registered in the database but it seems that it's not working.

When i try to outputDebugString the "compare" var it says "Excpected String at argument 1, got nil"

So i think i don't use the dbPoll very well.

Can someone help me ?

  
-- Check if a user already exsit in database 
function checkIfUserExist() 
    outputDebugString("Check if in checkIfUserExist Function - OK") 
    local query = dbQuery(connect, "SELECT account FROM Player WHERE account = ?", account) 
    local result = dbPoll(query, -1) 
    local compare = result[1] 
    outputDebugString(compare) 
    if compare then 
        local compAccount = compare.account 
        outputDebugString(compAccount) 
        if compAccount == account then 
            return 1 -- User already exist in DB 
        else 
            return 0 -- User doesn't exist in DB 
        end 
    else 
        return 0 
    end 
end 
  

Thanks.

Link to comment
  
  
-- Check if a user already exsit in database 
function checkIfUserExist() 
    outputDebugString("Check if in checkIfUserExist Function - OK") 
    local query = dbQuery(connect, "SELECT account FROM Player WHERE account = ?", account) 
    local result = dbPoll(query, -1) 
    local compare = result[1] 
    if compare then 
        outputDebugString(compare) 
        local compAccount = compare.account 
        outputDebugString(compAccount) 
        if compAccount == account then 
            return 1 -- User already exist in DB 
        else 
            return 0 -- User doesn't exist in DB 
        end 
    else 
        return 0 
    end 
end 
  
  

Link to comment

Here is what i did to made it work.

I can't see any difference except a "OutputDebugScript" moved 0.o

Maybe its better to let a little commentary when u change something.

  
-- Check if a user already exsit in database 
function checkIfUserExist() 
    outputDebugString("Check if in checkIfUserExist Function - OK") 
    local theAccount = getPlayerAccount(source) 
    local account = getAccountName(theAccount) 
    local query = dbQuery(connect, "SELECT account FROM Player WHERE account = ?", account) 
    local result = dbPoll(query, -1) 
    local compare = result[1] 
    if compare then 
        local compAccount = compare.account 
        outputDebugString(compAccount) 
        if compAccount == account then 
            return 1 -- User already exist in DB 
        else 
            return 0 -- User doesn't exist in DB 
        end 
    else 
        return 0 
    end 
end 
  

Link to comment
Here is what i did to made it work.

I can't see any difference except a "OutputDebugScript" moved 0.o

Maybe its better to let a little commentary when u change something.

  
-- Check if a user already exsit in database 
function checkIfUserExist() 
    outputDebugString("Check if in checkIfUserExist Function - OK") 
    local theAccount = getPlayerAccount(source) 
    local account = getAccountName(theAccount) 
    local query = dbQuery(connect, "SELECT account FROM Player WHERE account = ?", account) 
    local result = dbPoll(query, -1) 
    local compare = result[1] 
    if compare then 
        local compAccount = compare.account 
        outputDebugString(compAccount) 
        if compAccount == account then 
            return 1 -- User already exist in DB 
        else 
            return 0 -- User doesn't exist in DB 
        end 
    else 
        return 0 
    end 
end 
  

Did it output something??

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