Senze Posted March 17, 2010 Share Posted March 17, 2010 Hey Guys I ve got a problem with mysql so the problem is i want to but a value named admin from a player to setelementdata but how i can do this i try this local admin_query = mysql_query(connectHandler, "SELECT Admin FROM players") if(not admin_query)then outputDebugString("Unegueltige Query Aufuehrung!") else outputDebugString("Gueltige Query Aufuehrung!") setElementData(source, "Admin", tostring(admin_query)) end mysql_free_result(admin_query) but nothing is happen =( i hope you can help me :> Link to comment
50p Posted March 17, 2010 Share Posted March 17, 2010 What do you want "Admin" data to be? You don't want the query to be stored in element's data, do you? Link to comment
Senze Posted March 18, 2010 Author Share Posted March 18, 2010 no i know this is stupid but is was 3 am so no i want to store the value Admin from a specific player from my table players and put this value to a players element data because its much easier later to use getElementData for check if the player is an admin but i dont know how to handle this =/ its will be cool if you or another on can help me =) Link to comment
robhol Posted March 18, 2010 Share Posted March 18, 2010 You... you're not that steady in SQL, are you. For one thing, your query is just wrong, you need a WHERE clause to get from one player, or a selection of players. This returns for ALL players. For another, mysql_query doesn't return a result. As in PHP, you need to do more to get the resulting data itself. In this case, mysql_result, mysql_rows_assoc or one of those functions. Link to comment
Senze Posted March 18, 2010 Author Share Posted March 18, 2010 thx rob after you post i try it with assoc and the example from the wiki and so .. it works =) so thank you =) if(not admin_query)then outputDebugString("Unegueltige Query Aufuehrung!") else outputDebugString("Gueltige Query Aufuehrung!") for k, row in mysql_rows_assoc(admin_query) do if (row["Admin"] == mysql_null()) then else setElementData(source, "Admin", tonumber(row["Admin"])) end end end mysql_free_result(admin_query) 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