'LinKin Posted March 1, 2015 Posted March 1, 2015 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.
3B00DG4MER Posted March 1, 2015 Posted March 1, 2015 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
Noki Posted March 1, 2015 Posted March 1, 2015 Actually, whatever is in the square brackets is the row number, and "account" would be the column name.
'LinKin Posted March 1, 2015 Author Posted March 1, 2015 Idk if you understand, but the table is empty. outputChatBox(#result) => 0 Need a clanwar script? Click here! Do you want some free scripts for your DD server? Visit my website.
WhoAmI Posted March 1, 2015 Posted March 1, 2015 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.
ahmedo01 Posted March 1, 2015 Posted March 1, 2015 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)
3B00DG4MER Posted March 1, 2015 Posted March 1, 2015 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
'LinKin Posted March 1, 2015 Author Posted March 1, 2015 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.
3B00DG4MER Posted March 1, 2015 Posted March 1, 2015 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
WhoAmI Posted March 2, 2015 Posted March 2, 2015 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.
'LinKin Posted March 2, 2015 Author Posted March 2, 2015 Omg, it works! Thank you! May I know where you readed about this? Need a clanwar script? Click here! Do you want some free scripts for your DD server? Visit my website.
WhoAmI Posted March 2, 2015 Posted March 2, 2015 https://wiki.multitheftauto.com/wiki/dbQuery On the bottom of site.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now