Jump to content

[HELP] MySQL


Senze

Recommended Posts

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

no i know this is stupid but is was 3 am xD

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...