Jump to content

mysql error


fikasS

Recommended Posts

Posted
Hi, I have a little problem! dbPoll failed; The "character names" field has no default value

First of all, what is its default value? because this is an outdated mysql that was perfected 5 years ago. dbquery, db_free db_pool functions. Thank you in advance for your help.

 

CODE:

local hostname = "127.0.0.1"
local username = "...username"
local password = ".....pass"
local database = "databasename"
local results = {}

addEventHandler("onResourceStart", resourceRoot, function()
    dbHandler = dbConnect("mysql","dbname=".. database ..";host="..hostname, username, password, "autoreconnect=1")
    if not dbHandler then
        outputDebugString("#1 failed connect")
        cancelEvent(true)
    else
        outputDebugString("#2 succesful connect")
    end
end)

function query_free(q,poll)
    local this = #results + 1
    results[this] = dbQuery(dbHandler, q)
    if poll then
        local result, num_affected_rows, last_insert_id = dbPoll(results[this], -1)
        if result == nil then
            dbFree(results[this])
            return this, nil
        elseif result == false then
            dbFree(results[this])
            return this, nil
        else
            dbFree(results[this])
            return this, tonumber(last_insert_id)
        end
    end
    dbFree(results[this])
    return this
end

function getConnection()
    return dbHandler
end

  • Moderators
Posted
On 05/07/2022 at 14:27, fikasS said:

First of all, what is its default value?

Default value is used to fill in specific columns when you have no value provided for them.

Normally the default value is null, when nothing is provided.

 

Solutions:

https://stackoverflow.com/questions/41077044/mysql-can-not-insert-because-no-default-value

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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