Gossamer Forum
Home : Products : DBMan : Customization :

quick question on an 'if'

Quote Reply
quick question on an 'if'
Code:
if ($rec{'Avatar Address'}) {
print qq|
<img src=$url{'Avatar Address'}>
|;

ok what Im wanting to do is
if $rec{'Avatar Address'} reports back as empty
display a default picture
everything Ive tried as broken and not given a 500 error so I can't catch it that way.

this is going under the sub for printing records

so in common english I suppose

if {there is information stored in $rec{Avatar Address} print the image
if the $rec{Avatar...} is blank, dont print it (havent decided on whether to use a default 'no picture selected' image or to just leave it blank

what I currently have, should do that above...but instead it prints a red X box
I used the configarator(sp) to create the base for me to design around (thank you so much for that tool as well)
but it predefines $rec{'Avatar Address'} as
$url{'Avatar Address'}

Code:
$url{'Avatar Address'} = $rec{'Avatar Address'};
$url{'Avatar Address'} =~ s/<\/?B>//g;
-keeps thinking outloud-



any pointers to the correct direction would be most appriciated.

Last edited by:

zeroisgod42: Apr 3, 2003, 8:13 PM
Quote Reply
Re: [zeroisgod42] quick question on an 'if' In reply to
try

Code:
if ($rec{'Avatar Address'}) {
print qq|
<img src=$rec{'Avatar Address'}>
|;


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Quote Reply
Re: [zeroisgod42] quick question on an 'if' In reply to
Can you paste in a copy of a URL that is failing?

such as

http://www.xxx.com/cgi-bin/adjdb.cgi?db=adjproductview&ProductValidated=Yes

Also, maybe modify the current section with printing to give you more clues, such as;

Code:
if ($rec{'Avatar Address'}) {print qq| <img src=$url{'Avatar Address'}>
|; }

print qq| URL = $url{'Avatar Address'} REC = $rec{'Avatar Address'} # JUST TO SEE WHAT THE VALUES ARE
|;

Also, I'm not sure how you are specifing the URL path, or is it all included in the $rec{'Avatar Address'} ?

That is to say, What is a typical value for $rec{'Avatar Address'}?

Last edited by:

joematt: Apr 4, 2003, 9:03 AM
Quote Reply
Re: [esm] quick question on an 'if' In reply to
Use an "else"

if ($rec{'Avatar'}) { print qq|<img src="http://www.blah.com/avatar.jpg"> |;}
else
{print qq| <img src="http://www.blah.com/no-image.jpg"> |;}

Not sure how you are letting the address come into the database... all are avatars stored in the same location?

For example I use ID's in some files like this.

print qq| <IMAGE SRC="http://mydomain.com/images/$rec{'ID'}.jpg"> |;

Which would then (for record 1234) would return:

1234.jpg

Good Luck!

Last edited by:

Watts: Apr 4, 2003, 4:11 PM
Quote Reply
Re: [Watts] quick question on an 'if' In reply to
For if/else I've got used to using a "question" style of syntax - gets rid of clunky brackets...

Code:
print $rec{Avatar} ?
qq|<img src="http://www.blah.com/avatar.jpg"> | :
qq|<img src="http://www.blah.com/no-image.jpg"> |;
Quote Reply
Re: [Paul] quick question on an 'if' In reply to
Cool! Thanks! I read that somewhere once, but had to dump that memory address for new stuff - clearing the old "brain cache" and all.