Jump to content

getPlayerName with MySQL


dawid4157

Recommended Posts

Why this function does not work?

function zapytanie(player) 
    local playerName = getPlayerName(player) 
    local register = mysql_query(handler, "INSERT INTO `Players` SET `Nick` = ".. playerName .." ") 
    outputChatBox("Poprawne zapytanie") 
end 

When I set this:

function zapytanie(player) 
    local playerName = getPlayerName(player) 
    local register = mysql_query(handler, "INSERT INTO `Players` SET `Nick` = 'dawid4157' ") 
    outputChatBox("Poprawne zapytanie") 
end 

code work good. Why? How use getPlayerName correctly? Please help.

Link to comment
function zapytanie(player) 
    local playerName = getPlayerName(player) 
    local register = mysql_query(handler, "INSERT INTO `Players` SET `Nick` = `".. playerName .."` ") 
    outputChatBox("Poprawne zapytanie") 
end 

Try this

Link to comment

I show all code:

local host = 'host' 
local user = 'user' 
local password = 'pass' 
local db = 'database' 
handler = mysql_connect(host, user, password, db) 
if (handler) then 
    outputChatBox("Connected to the Database!", getRootElement(), 255, 000, 000) 
    outputDebugString("Connected to the Database!") 
else 
    outputChatBox("No connected to the Database!") 
    outputDebugString("No connected to the Database!") 
end 
  
  
function zapytanie(player) 
    local playerName = getPlayerName(player) 
    local register = mysql_query(handler, "INSERT INTO `Gracze` SET `Nick`=? ", playerName ) 
    outputChatBox("Poprawne zapytanie") 
end 
  
  
  
addCommandHandler("sql", zapytanie) 

What is wrong?

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