'LinKin Posted March 1, 2015 Share 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.. Link to comment
3B00DG4MER Posted March 1, 2015 Share 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 Link to comment
Noki Posted March 1, 2015 Share Posted March 1, 2015 Actually, whatever is in the square brackets is the row number, and "account" would be the column name. Link to comment
'LinKin Posted March 1, 2015 Author Share Posted March 1, 2015 Idk if you understand, but the table is empty. outputChatBox(#result) => 0 Link to comment
WhoAmI Posted March 1, 2015 Share 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. Link to comment
ahmedo01 Posted March 1, 2015 Share 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) Link to comment
3B00DG4MER Posted March 1, 2015 Share 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% Link to comment
'LinKin Posted March 1, 2015 Author Share 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 Link to comment
3B00DG4MER Posted March 1, 2015 Share 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 Link to comment
WhoAmI Posted March 2, 2015 Share 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. Link to comment
'LinKin Posted March 2, 2015 Author Share Posted March 2, 2015 Omg, it works! Thank you! May I know where you readed about this? Link to comment
WhoAmI Posted March 2, 2015 Share Posted March 2, 2015 https://wiki.multitheftauto.com/wiki/dbQuery On the bottom of site. Link to comment
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