Jump to content

SQL Query


'LinKin

Recommended Posts

Posted

Hi,

I'm trying to avoid concatenating a string to send it as a query for MySQL, So I have this code:

local result = dbPoll(dbQuery(dbHandler, "SELECT ? FROM `stats` WHERE `account`=?", column, accName), -1) 
outputChatBox(type(result)) 
outputChatBox(#result) 

It says:

- table

- 0

I can't access the value returned..

Need a clanwar script? Click here!

Do you want some free scripts for your DD server? Visit my website.

Posted
result[1].account -- 1 is the column, if there's many column you can just put number of it 
--account is the row name 

SAF/SAO - 30%

Skype: Themerzoug2020

in-game name:3B00DG4MER

xOG7h1J.png

Posted

Well, I don't know if it cause anything but it is good to try:

"SELECT `?` FROM `stats` WHERE `account`=`?`" 

Also make sure that 'column' gives correct value and there is such a column in database. Check if DB connection works fine, too.

Posted

Change query to

SELECT ? FROM stats WHERE account=?

I think it can work.

Or if not work

SELECT ? FROM stats WHERE account='?'

And this is what i am using

local result = dbPoll(dbQuery(dbHandler, "SELECT '"..column.."' FROM stats WHERE account='"..accName.."'"), -1)

Posted
result[1].account -- 1 is the column, if there's many column you can just put number of it 
--account is the row name 

I'm sure that this works 100%

SAF/SAO - 30%

Skype: Themerzoug2020

in-game name:3B00DG4MER

xOG7h1J.png

Posted
local result = dbPoll(dbQuery(dbHandler, "SELECT '"..column.."' FROM stats WHERE account='"..accName.."'"), -1)

That's what I'm trying to avoid.. (Concatenating a string)

result[1].account -- 1 is the column, if there's many column you can just put number of it 
--account is the row name 

I'm sure that this works 100%

It won't work since the table returned is empty

Need a clanwar script? Click here!

Do you want some free scripts for your DD server? Visit my website.

Posted

No

the table is not empty

Just try it and it will work

#result

returns number of rows

if they was

result = {

{},{},{},.....

}

But they're not Just try what i told you

SAF/SAO - 30%

Skype: Themerzoug2020

in-game name:3B00DG4MER

xOG7h1J.png

Posted

I think that I know what is wrong.

local result = dbPoll(dbQuery(dbHandler, "SELECT `??` FROM `stats` WHERE `account`=?", column, accName), -1) 

I read somewhere about those double question marks.

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