Script works locally, but fails remotely.
Script works locally, but fails remotely.
am 19.04.2006 17:11:06 von Justin C
I've written a script for the gallery section of my employers web-site.
The script shows thumbnail images of products depending on the artist
selected. The thumb-nails can then be clicked to view a larger image.
This all works as expected on our local machine (Perl 5.8.7), but on our
ISP's server most of the script works apart from clicking the thumb-nail
for a larger image. At this point it always returns the very first image
from the list of available images, regardless of which image is
requested. I've been in touch with our ISP and they're running Perl
5.8.0, not exactly a major release change so I can't figure out what's
wrong.
Looking at the link to get the larger image (where the script is failing
to act as expected) I can see that the first parameter, which should be
a single character A-Z or 'num', must be undef. It seems all the
variables have 'moved up one position' and the last variable is then
returning 0 - and thereby showing the image of the first item on the
list.
The part of the script that generates this part of the html is at lines
225 and 239 (the reasons for both of these parts being almost identical
is that an item count exists and, after 5 items, the table row is closed
and a new row started - I can see better ways of doing this now and will
refine it later, it's not, from what I can see, the problem, it's just
ugly code).
The script opens a text file which is divided into fields by colons. The
first field is a count/line-number and is, therefore, unique to each
item/line. The rest of each line gives various information about each
available item and is used to fill in the html and description parts of
the web-pages. The file can be viewed here.
http://masonsmusic.demonweb.co.uk/perl/shirts.test
I've uploaded the script to:
http://masonsmusic.demonweb.co.uk/perl/index.txt
and the script can be seen in action at:
http://masonsmusic.demonweb.co.uk/gallery/index.cgi
There are no images as yet but that shouldn't stop the script. The
script is quite long and I apologise for the state of the code (I'm
no expert, sorry), I have tried to comment the code as best I can.
If you can find the time to look at this and give me some ideas or clues
I'd be very grateful. I've been staring at it for quite a few days now
and have no clue.
Justin.
--
Justin C by the sea.
Re: Script works locally, but fails remotely.
am 19.04.2006 23:07:08 von Matt Garrish
"Justin C" wrote in message
news:slrne4ckoa.vge.justin.0511@stigmata.purestblue.com...
> I've written a script for the gallery section of my employers web-site.
> The script shows thumbnail images of products depending on the artist
> selected. The thumb-nails can then be clicked to view a larger image.
>
> This all works as expected on our local machine (Perl 5.8.7), but on our
> ISP's server most of the script works apart from clicking the thumb-nail
> for a larger image. At this point it always returns the very first image
> from the list of available images, regardless of which image is
> requested.
I downloaded your code and it works fine on my machine under 5.8.5, so there
must either be something screwy with your ISPs install, or there was a bug
in sprintf that's turning your $key value into 0s. Trying rewriting that
piece of code to not use printf (i.e., just concatenate the values), and see
if it works as expected. That may be your only solution.
Matt
Re: Script works locally, but fails remotely.
am 19.04.2006 23:35:38 von Matt Garrish
"Matt Garrish" wrote in message
news:YDx1g.1895$DR6.137924@news20.bellglobal.com...
>
> "Justin C" wrote in message
> news:slrne4ckoa.vge.justin.0511@stigmata.purestblue.com...
>> I've written a script for the gallery section of my employers web-site.
>> The script shows thumbnail images of products depending on the artist
>> selected. The thumb-nails can then be clicked to view a larger image.
>>
>> This all works as expected on our local machine (Perl 5.8.7), but on our
>> ISP's server most of the script works apart from clicking the thumb-nail
>> for a larger image. At this point it always returns the very first image
>> from the list of available images, regardless of which image is
>> requested.
>
> I downloaded your code and it works fine on my machine under 5.8.5, so
> there must either be something screwy with your ISPs install, or there was
> a bug in sprintf that's turning your $key value into 0s. Trying rewriting
> that piece of code to not use printf (i.e., just concatenate the values),
> and see if it works as expected. That may be your only solution.
>
Out of curiosity I downgraded to 5.8.0 and there's definitely a bug in
printf. After looking a little more at your code I see now what you mean
about it shifting your values. For whatever reason the first argument to
printf is being ignored, so the path winds up being formatted as a number
hence the 0s.
As a hack, you could send an "undef" as the first argument, but then that
would screw up your test environment. I don't see a pressing need to use
printf here, however, so you might want to consider my first advice and just
concatenate the strings and print them.
Matt
Re: Script works locally, but fails remotely.
am 20.04.2006 13:20:30 von Justin C
On 2006-04-19, Matt Garrish wrote:
>
> "Matt Garrish" wrote in message
> news:YDx1g.1895$DR6.137924@news20.bellglobal.com...
>>
>> "Justin C" wrote in message
>> news:slrne4ckoa.vge.justin.0511@stigmata.purestblue.com...
>>> I've written a script for the gallery section of my employers web-site.
>>> The script shows thumbnail images of products depending on the artist
>>> selected. The thumb-nails can then be clicked to view a larger image.
>>>
>>> This all works as expected on our local machine (Perl 5.8.7), but on our
>>> ISP's server most of the script works apart from clicking the thumb-nail
>>> for a larger image. At this point it always returns the very first image
>>> from the list of available images, regardless of which image is
>>> requested.
>>
>> I downloaded your code and it works fine on my machine under 5.8.5, so
>> there must either be something screwy with your ISPs install, or there was
>> a bug in sprintf that's turning your $key value into 0s. Trying rewriting
>> that piece of code to not use printf (i.e., just concatenate the values),
>> and see if it works as expected. That may be your only solution.
>>
>
> Out of curiosity I downgraded to 5.8.0 and there's definitely a bug in
> printf. After looking a little more at your code I see now what you mean
> about it shifting your values. For whatever reason the first argument to
> printf is being ignored, so the path winds up being formatted as a number
> hence the 0s.
>
> As a hack, you could send an "undef" as the first argument, but then that
> would screw up your test environment. I don't see a pressing need to use
> printf here, however, so you might want to consider my first advice and just
> concatenate the strings and print them.
Thank you for re-assuring me of my sanity! I'm not too fussed about the
local and remote scripts being different. I've had to put up with that
for a while anyway, my ISPs "Showroom" account has a nightmarish
file-system hierarchy that we have to adhere to. Luckily we're moving it
all to a more straightforward hosting service now, so the suggested
"undef" hack is simplicity compared to what I'm used to. However, I'll
go with the re-write to avoid printf, it's cleaner.
Thank you for looking into this and your suggestions for a solution.
Justin.
--
Justin C by the sea.