Jump to content

[HELP] Please help, Issue with Lua and Boolean


Recommended Posts

Hello! Thank you for taking your time to look at this. I have a Roleplay server, And everything is goin well, Exept the login. In the console when i hit Login, I get this: attempt to compare number with boolean

Here is where it says the error is:

local accountCheckQuery = mysql:query(accountCheckQueryStr)

if mysql:num_rows(accountCheckQuery)>0 then

accountData = mysql:fetch_assoc(accountCheckQuery)

mysql:free_result(accountCheckQuery)

Please help, Thanks in advanced!

Link to comment
  • Moderators
local accountCheckQuery = mysql:query(accountCheckQueryStr)  
-- get database account 

Script problem:

mysql:num_rows(accountCheckQuery)  
-- returns boolean =  false/true at the moment 

if mysql:num_rows(accountCheckQuery)>0 then  
-- here you are comparing the boolean with the number 0. 

and how the solve it?

I have no idea, because this is the result from something that went wrong at another part of the script.

Link to comment
  
if mysql:num_rows(accountCheckQuery)>0 then 

is bad

use

if accountCheckQuery:num_rows() > 0 then 

all:

  
local accountCheckQuery = mysql:query(accountCheckQueryStr) 
if accountCheckQuery:num_rows() > 0 then 
accountData = mysql_fetch_assoc(accountCheckQuery) 
accountCheckQuery:free_result() 
  

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