Jump to content

Returns nil... Why?


GTX

Recommended Posts

Hello. I was trying to make "protection" for my script.

function CHECKING() 
    result = mysql_query(connect_mysql_check, "SELECT name FROM granted") 
    if (result) then while true do 
        local row = mysql_fetch_assoc(result) 
         
        if not row then 
            break end 
             
            if getParticalServerName(row.name) then 
                CONNECT() 
            else 
  
                WRONG() 
            end 
        end 
    end 
    mysql_free_result(result) 
end 
  
connect_mysql_check = mysql_connect(host, user, password, database_, 3306, "/var/run/mysqld/mysqld.sock") 
if not connect_mysql_check then 
  outputChatBox("#FF8800[TOPTIMES] #FF6565Could not connect with MySQL Server.", getRootElement(), 255, 255, 255, true) 
else 
  setTimer(CHECKING, 500, 1) 
end 

local row = mysql_fetch_assoc(result) at line 4 returns nil. Why?

Link to comment

try this:

function CHECKING() 
    result = mysql_query(connect_mysql_check, "SELECT * FROM granted") 
    if (result) then 
        local row = mysql_fetch_assoc(result) 
        
        if not row then 
         errno=mysql_errno (connect_mysql_check) 
         outputDebugString("Sorry, the result was not returned. Here's a error number: "..errno.." .",1) 
            break end 
            
            if getParticalServerName(row.name) then 
                CONNECT() 
            else 
  
                WRONG() 
            end 
        end 
    end 
    mysql_free_result(result) 

Edited by Guest
Link to comment

oh, snap, srry, I was looking at something else

EDIT: try this:

connect_mysql_check = mysql_connect(host, user, password, database_, 3306, "/var/run/mysqld/mysqld.sock") 
if not connect_mysql_check then 
  outputChatBox("#FF8800[TOPTIMES] #FF6565Could not connect with MySQL Server.",root, 255, 255, 255, true) 
else 
  setTimer(CHECKING, 500, 1) 
end 
  
function CHECKING() 
    result = mysql_query(connect_mysql_check, "SELECT name FROM granted") 
    if (result) then 
        local row = mysql_fetch_assoc(result) 
        if not row then outputDebugString("Sorry, but the row was not returned") end 
            if getParticalServerName(row.name) then 
                CONNECT() 
            else 
  
                WRONG() 
            end 
    end 
    mysql_free_result(result) 
end 

Link to comment
Hello. I was trying to make "protection" for my script.
function CHECKING() 
    result = mysql_query(connect_mysql_check, "SELECT name FROM granted") 
    if (result) then while true do 
        local row = mysql_fetch_assoc(result) 
         
        if not row then 
            break end 
             
            if getParticalServerName(row.name) then 
                CONNECT() 
            else 
  
                WRONG() 
            end 
        end 
    end 
    mysql_free_result(result) 
end 
  
connect_mysql_check = mysql_connect(host, user, password, database_, 3306, "/var/run/mysqld/mysqld.sock") 
if not connect_mysql_check then 
  outputChatBox("#FF8800[TOPTIMES] #FF6565Could not connect with MySQL Server.", getRootElement(), 255, 255, 255, true) 
else 
  setTimer(CHECKING, 500, 1) 
end 

local row = mysql_fetch_assoc(result) at line 4 returns nil. Why?

I think MySQL need ` `.

Like this:

mysql_query ( connect_mysql_check, "SELECT `name` FROM `granted`" ) 

Also, check if connect_mysql_check returns 1.

Link to comment
I think MySQL need ` `.

Like this:

mysql_query ( connect_mysql_check, "SELECT `name` FROM `granted`" ) 

Also, check if connect_mysql_check returns 1.

Oh,ya, nice thinking, i totally forgot about that part, nice work

and the connect_mysql_check returned...

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