Dimmi 19 Posted May 13, 2015 Share Posted May 13, 2015 Hi guys. How can I make a function to select a string (varchar in database) in a quest. For example, to select "test" (which is an integer) from table "test", I use a function like this: function get_test () local r = mysql.query("SELECT test FROM player.test LIMIT 1") return r[1][1] end How can I make a function to select a string? Please help! Link to comment Share on other sites More sharing options...
Benhero 23 Posted May 13, 2015 Share Posted May 13, 2015 maybe return tostring(r[1][1]) ? or... function get_test(text) local r = mysql_query("SELECT " ..text.. " FROM player.test LIMIT 1") return tostring(r[1][1]) end Link to comment Share on other sites More sharing options...
Dimmi 19 Posted May 14, 2015 Author Share Posted May 14, 2015 It returns nil but thanks for advice, anyway... Link to comment Share on other sites More sharing options...
Premium Cataclismo 86 Posted May 14, 2015 Premium Share Posted May 14, 2015 It returns nil but thanks for advice, anyway... That's strange. It should actually work exactly how selecting integer works. Try using extended MySQL query: SELECT `column` FROM player.table LIMIT 1; Also, do you use source? It would be easier to use the source. Link to comment Share on other sites More sharing options...
Dimmi 19 Posted May 14, 2015 Author Share Posted May 14, 2015 It returns nil but thanks for advice, anyway... That's strange. It should actually work exactly how selecting integer works. Try using extended MySQL query: SELECT `column` FROM player.table LIMIT 1; Also, do you use source? It would be easier to use the source. Yes, I'm using source. Function I used (mysql.query) was added by source, but the query it's ok, cuz' always I test my query in Navicat. The problem is in variable (I think), because integer variable works. Link to comment Share on other sites More sharing options...
Premium V0iĐ 114 Posted May 14, 2015 Premium Share Posted May 14, 2015 Could you show your mysql query function? Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now