Jump to content

[HELP] Getting value from MySQL Database


Azaroth

Recommended Posts

Posted

Hello.

How to get value from MySQL Databasa? I tried mysql_query and mysql_fetch_field. mysql_query returns: MySQL result (#32) and mysql_fetch_field return field name.

Posted
local query = dbQuery( handler, "SELECT * FROM pickups" )  

It's not working. :/

I get warning:

Bad argument @ 'dbQuery' [Expected db-connection at argument 1, got userdata]

Posted

It's connected with mysql_connect.

handler = mysql_connect("localhost", "root", "pass", "multi theft auto") 

@EDIT:

Ok. Connected with DbConnect and got values with dbPoll, but I don't understand that dbPoll. Can someone explain me how it works?

local query = dbQuery( connection, "SELECT * FROM pickups WHERE UID="..i) 
local result, numrows, errmsg = dbPoll ( query, -1 ) 
  
if numrows > 0 then 
  
    for result, row in pairs ( result ) do 
        -- by using a second loop (use it if you want to get the values of all columns the query selected): 
        for column, value in pairs ( row ) do 
            -- column = the mysql column of the table in the query 
            -- value = the value of that column in this certain row 
        end 
  
        -- or without a second loop (use it if you want to handle every value in a special way): 
        outputChatBox ( row["column"] ) -- it will output the value of the column "column" in this certain row 
    end 
  
end 

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...