Jump to content
  • 0

how to check if var empty


Question

Posted (edited)

hello,

how can i check if a variable is empty?

 

my code(not all):

query_sql "SELECT `last_mac` FROM `login` WHERE `char_id` = " + getcharid(0) + "", .@lastmac;

the fild "last_mac" can be empty because of this

COLUMN `last_mac` VARCHAR(18) NOT NULL DEFAULT ''

 But how can i check this with a if? This dont work

if (.@lastmac == )
{
bla bla
}
Edited by Vincent

4 answers to this question

Recommended Posts

Posted

your script will end up failed...

  1. variable is not saved as string
  2. login table dont have char_id column

it should be like this

query_sql( "SELECT `last_mac` FROM `login` WHERE `account_id` = "+getcharid(3), .@lastmac$ );

then to check if the MAC address is empty or not..

if( .@lastmac$[.@i] == "" ){
   // mac address is empty
}
  • Upvote 1
  • 0
Posted (edited)

So 

 if (!.var)

means 'if var is empty' ?

If I want it to be true if not empty, should i only use :

if (.var)

Or should I use

if (!(!.var))

?

 

I was afraid that !.var would only check if .var exists, not validate its value.

Edited by klesler

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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