Premium Lorthir 0 Posted April 19, 2015 Premium Share Posted April 19, 2015 Hello! I'm trying to count the number of entries that I've in this table, but my function isnt working! local kills = mysql_query("SELECT COUNT(*) FROM database.table") Can anybody fix this? Link to comment Share on other sites More sharing options...
Alina 234 Posted April 19, 2015 Share Posted April 19, 2015 The query is correct. Can you show us what you're doing with "kills" after the query executed? Also make sure your quest can use mysql queries via mysql_query() function Link to comment Share on other sites More sharing options...
Premium Lorthir 0 Posted April 19, 2015 Author Premium Share Posted April 19, 2015 yes The query is correct. Can you show us what you're doing with "kills" after the query executed? Also make sure your quest can use mysql queries via mysql_query() function I'm trying after that to make and if statment comparing a number and the return of the query! example: if kills >= 3 then syschat("hi") end Link to comment Share on other sites More sharing options...
Premium Izaya 15 Posted April 19, 2015 Premium Share Posted April 19, 2015 Well of course this won't work because mysql_query returns table (if you are using mijago's function). You propably wan't to do it like this: local kills = mysql_query("SELECT COUNT(*) FROM database.table")[1][1] 3 Link to comment Share on other sites More sharing options...
Premium Lufbert 20 Posted April 19, 2015 Premium Share Posted April 19, 2015 And query didn't return a number but string. You must edit if kills ... To if tonumber(kills) ... Link to comment Share on other sites More sharing options...
layfon 4 Posted April 19, 2015 Share Posted April 19, 2015 Hello! I'm trying to count the number of entries that I've in this table, but my function isnt working! local kills = mysql_query("SELECT COUNT(*) FROM database.table") Can anybody fix this? local kills = mysql_query("SELECT COUNT(*) FROM database.table") local row = table.getn(kills) say("Kill : "..row) try this 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