Jump to content

[Help] Database Error


djharbi2

Recommended Posts

Hi, I want to print the matching value but I can't 

Can you help, thank you ...

server.Lua

local vehDB = dbConnect( 'sqlite', 'vehicle.db' )
dbExec(vehDB,' CREATE TABLE IF NOT EXISTS `vehicle_base` (pAcc, vehicleID, vehicleName, vehiclePrice, vehicleStatus, vehicleHP)')

function dategetV()
local results = dbPoll(dbQuery(vehDB, "SELECT * FROM `vehicle_base` WHERE vehicleID=? AND pAcc=?",520,getAccountName(getPlayerAccount(source))), -1) 
 if results then 
            for k,v in ipairs ( results ) do 
            outputDebugString(tostring(v['vehicleHP']))
        end 
    end 
end
addEvent("dategetV", true)
addEventHandler("dategetV", getRootElement(getThisResource()), dategetV)
Edited by djharbi2
Link to comment
3 hours ago, djharbi2 said:

want to pull the vehicleHP value of the matching person

For example:
djharbi, 520, infernus, 100, good,1000 (This is a sample data)

The data I want > 1000 (vehicleHP)
 

That's exactly what your code does. So what's your issue? Nothing prints out even if the value exists in the database?

Link to comment
19 minutes ago, djharbi2 said:

If you recreate the above code, I would be glad, you can do it

local vehDB = dbConnect("sqlite", "vehicle.db")
dbExec(vehDB, "CREATE TABLE IF NOT EXISTS vehicle_base (pAcc TEXT, vehicleID TEXT, vehicleName TEXT, vehiclePrice TEXT, vehicleStatus TEXT, vehicleHP TEXT)")

function dateGetV()
	local accName = getAccountName(getPlayerAccount(source))
	local qh = dbQuery(vehDB, "SELECT * FROM vehicle_base WHERE vehicleID=? AND pAcc=?", "520", accName)
	local result = dbPoll(qh, -1)
	if result then
		for _, row in ipairs(result) do 
			outputDebugString(row["vehicleHP"])
        end 
    end 
end
addEvent("dategetV", true)
addEventHandler("dategetV", root, dateGetV)

I'd do like this.

Edited by HassoN
  • Like 1
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...