Gossamer Forum
Quote Reply
question on null
To test if a variable returned from a database has a value or is defined do you go: if $LinkID == null or do you go if $LinkID = ""
Quote Reply
Re: [scorpioncapital] question on null In reply to
It depends what it is in the database - they are different. Have a look in the database using mysqlman and see whether the field you are testing says NULL or is just an empty field.
Quote Reply
Re: [afinlr] question on null In reply to
my code is:

my $table = $DB->table('Links','CatLinks');
my $sth = $table->select( { Live_Date => "$Date" },{ CategoryID => '7' } ,{ CategoryID => '7' } );
my $LinkID;
while (my $hit = $sth->fetchrow_hashref) {
$LinkID = $hit->{ID};
}
my $details;
if ($LinkID) {

do this}

else {}

I guess I can always use the code:

if !($LinkID) {}

right?
Quote Reply
Re: [scorpioncapital] question on null In reply to
As far as I am aware if you have my $LinkID it is equivalent to my $LinkID = '';

So I think you should be able to use
if ($LinkID eq '') {...
or
if (!$LinkID) {...
or
unless ($LinkID) {...

Is there any reason why you have CategoryID => '7' twice? Think this line just needs to be this:
my $sth = $table->select( { Live_Date => "$Date", CategoryID => '7' } );
Quote Reply
Re: [afinlr] question on null In reply to
thanks, no idea why its twice but it works and I don't want to curse it by touching it :) Coding gives me a headache
Quote Reply
Re: [scorpioncapital] question on null In reply to
Wink Fair enough.