Gossamer Forum
Home : General : Perl Programming :

Poke me in the eye, I don't see the problem!

Quote Reply
Poke me in the eye, I don't see the problem!
Here's my code in sub build_html_record_form:

Code:
if ($rec{'Imagename_1'}) { # Display image one
$image_1 = "<tr><td align=right valign=top width=20%><$font>Image 1:</font></td><td width=80%><img src=\"$upload_directory_url/$rec{$db_key}/$rec{'Imagename_1'}\"></td></tr>\n"
}
if ($rec{'Imagename_2'}) { # Display image two
$image_1 .= "<tr><td align=right valign=top width=20%><$font>Image 2:</font></td><td width=80%><img src=\"$upload_directory_url/$rec{$db_key}/$rec{'Imagename_2'}\"></td></tr>\n"
}
if ($rec{'Imagename_3'}) { # Display image three
$image_1 .= "<tr><td align=right valign=top width=20%><$font>Image 3:</font></td><td width=80%><img src=\"$upload_directory_url/$rec{$db_key}/$rec{'Imagename_3'}\"></td></tr>\n"
}
else {
$image_1 = "";
}

Further on in the same sub the above code is called with: $output .= qq~$image_1~;
Situation: If I upload 2 or 3 images, they display in the admin validation form fine using both 'add validation' or 'admin modification'. If I load upload just one pic, it does not show. The image name is in the correct db position in all cases, so no problem there. Wierd: if in 'admin modification' I put ANYTHING in the other imagename fields via admin modify (like, just one letter, not through the upload form), then the lone image will display as it should. I have tried dozens of variations of the code, and always get the same result. Driving me crazy!!

The image IS uploaded, and will show on the site page (via link.html), if I validate the addition, even though I can't see the picture in admin.

HELP! Crazy w00t


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Poke me in the eye, I don't see the problem! In reply to
Try:

Code:
my $image_n = $rec{'Imagename_1'};
$image_1 = "<tr><td align=right valign=top width=20%><$font>Image 1:</font></td><td width=80%><img src=\"$upload_directory_url/$rec{$db_key}/$image_n\"></td></tr>\n"

Also, no need to use " all the time , and escaping. try using qq||;


Code:
my $image_n = $rec{'Imagename_1'};
$image_1 = qq|<tr><td align=right valign=top width=20%><$font>Image 1:</font></td><td width=80%><img src="$upload_directory_url/$rec{$db_key}/$image_n"></td></tr>\n|;

Hope that helps (this may not be the probelm, but just wanted to point them out :)). Afraid I can't see anything else really wrong with that code.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Poke me in the eye, I don't see the problem! In reply to
Thanks Andy. I simplified the code, made a few changes, works OK now.
Code:
# >>> Image Upload mod
if ($in{'db'} eq 'links') { # Make sure we're editing links, not categories.
# Get the file from /pics if there is one.
if ($rec{'Imagename_1'}) { # Display image one.
$image_1 = qq|<tr><td align="right" valign="top" width="20%"><$font>Image 1:</font></td><td width="80%"><img src="$upload_directory_url/$rec{$db_key}/$rec{'Imagename_1'}" /></td></tr>\n
<tr><td align="right" valign="top" width="20%"><$font>Delete Image 1?</font></td><td width="80%"><input type="checkbox" name="delete_1" value="yes" /></td></tr>\n|;
}
if ($rec{'Imagename_2'}) { # Display image two
$image_2 = qq|<tr><td align="right" valign="top" width="20%"><$font>Image 2:</font></td><td width=80%><img src="$upload_directory_url/$rec{$db_key}/$rec{'Imagename_2'}" /></td></tr>\n
<tr><td align="right" valign="top" width="20%"><$font>Delete Image 2?</font></td><td width="80%"><input type="checkbox" name="delete_2" value=\"yes\" /></td></tr>\n|;
}
if ($rec{'Imagename_3'}) { # Display image three
$image_3 = qq|<tr><td align="right" valign="top" width="20%"><$font>Image 3:</font></td><td width="80%"><img src="$upload_directory_url/$rec{$db_key}/$rec{'Imagename_3'}" /></td></tr>\n
<tr><td align="right" valign="top" width="20%"><$font>Delete Image 3?</font></td><td width="80%"><input type="checkbox" name="delete_3" value="yes" /></td></tr>\n|;
}
}
# <<<


Code:

# >>> Image Upload Mod
$output .= $image_1;
$output .= $image_2;
$output .= $image_3;
# <<<


Leonard
aka PerlFlunkie

Last edited by:

PerlFlunkie: Dec 8, 2009, 2:04 PM