/    Sign up×
Community /Pin to ProfileBookmark

Script not working on one server, but works on another

I’ve got a basic product gallery, populated by reading a directory. Clicking a thumb gives you a larger image in a pop-up. The script I’m using for the pop-up is this:

[code=php]
<html>
<head>
<title><?PHP print($photo); ?></title>
<link rel=”stylesheet” type=”text/css” href=”../assets/css/global.css”>
</head>

<?PHP
$photo_size = getimagesize(“$photo”);
?>

<body bgcolor=”#FFFFFF” marginheight=”0″
marginwidth=”0″ leftmargin=”0″ topmargin=”0″
rightmargin=”0″>

<div align=”center”>

<img border=”0″ src=”<?PHP print($photo); ?>” <?PHP print($photo_size[3]); ?> name=”photo”>

<br>
<br>

<a class=”prodLInk” href=”javascript:window.close()”>lukke</a>

</div>
</body>
</html>
[/code]

On my server, [url]http://www.slowcocoon.com/public/ksror/tips.htm[/url] , this works with no problems, but on my clients server, [url]http://www.ksrør.no/_test/tips.htm[/url], the gallery will load, but the pop-up image is not found (click ‘blandebatteri’, second item down to bring up some products). The path in the url is correct, and even the size of the window is set to match the image, but a view of the source shows the img src = ” “.

This is the script used in the gallery:

[code=php]
if($total_photos == 0){
print(“<td class=”body”>Kommer…</td>n”);
}

else for ($row=0; $row < $num_rows; $row++){
print(“<tr>n”);
for ($col=0; $col < $num_columns; $col++){
if($i < $total_photos){
$title = trim($photos[$i]);
$myTitle = split(‘[.]’, $title);
$thumbnail = $thumbnail_dir.trim($photos[$i]);
$thumb_image_size = getimagesize($thumbnail);
$image_size = getimagesize($img_dir.trim($photos[$i]));
$width = $image_size[1] + 50;
print(“<td align=”center” valign=”middle” width=”75″><a class=”prodLink” onFocus=”this.blur()” href=”javascript:photo_open(‘img/photo_display.php?photo=”.trim($photos[$i]).”‘,'”.$image_size[0].”‘,'”.$width.”‘);”><img border=”0″ src=””.$thumbnail.”” “.$thumb_image_size[3].”><br><br>”.$myTitle[0].”<br><br></a></td>n”);
} else {
print(“<td width=”75″><img src=”../../../../img/pr/pr_spcr_trans.gif” width=”75″></td>n”);
}
$i++;
}
print(“</tr>n”);
}
[/code]

I’ve check phpinfo on both servers and can see that we are both running Linux, but other than that I don’t know what to look for.

Php info’s are here:

My server – [url]http://www.slowcocoon.com/phpinfo.php[/url]
Client’s server – [url]http://www.ksrør.no/phpinfo.php[/url]

Could someone please have a look, or offer some advice?

to post a comment
PHP

10 Comments(s)

Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYJan 19.2006 — 

i think it has to do with the file name containing spaces
--



if you look on the ksrør site, and you put the mouse over the first image (in 'Blandebatteri') you can see that the link that calls the photo_open javascript function does contain the name..

try to change the file names to correct names
Copy linkTweet thisAlerts:
@fx2oooauthorJan 19.2006 — I thought of that too and removed them, but it didn't make a difference.

Check the third image now and you'll see.
Copy linkTweet thisAlerts:
@chazzyJan 19.2006 — is it possible they didn't install the image extensions?
Copy linkTweet thisAlerts:
@fx2oooauthorJan 19.2006 — Don't know, how whould I check that? phpinfo?

Would the gallery still be loading if this was the case?
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYJan 19.2006 — is it possible they didn't install the image extensions?[/QUOTE]
what image extensions do you mean chazzy?
Copy linkTweet thisAlerts:
@fx2oooauthorJan 20.2006 — Thanks for your efforts guys, just have to bump this as I'm desparate to get it fixed. Any other ideas, or info on the image extensions (chazzy)?

Maybe something to do with the javascript?
<i>
</i>function photo_open(link, w, h) {
var lPosition = (screen.width) ? (screen.width-w)/2 : 0;
var tPosition = (screen.height) ? (screen.height-h)/2 : 0;
var photoWindow = window.open(link,"photo","toolbar=0,top="+tPosition+",left="+lPosition+",directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width="+w+",height="+h);
}


What are the possible reasons why everything could work on one server, but not the other?
Copy linkTweet thisAlerts:
@chazzyJan 20.2006 — No, most likely nothing to do with javascript. That's browser related, not server related.

I would say, look at the "Configure Command" it's clearly much different between the two servers. The issue could be anywhere in there, permissions, etc. But does the same script create both the thumbnail and fullsize image?
Copy linkTweet thisAlerts:
@madddidleyJan 20.2006 — check that e_error_report thing or something like that.
Copy linkTweet thisAlerts:
@fx2oooauthorJan 20.2006 — But does the same script create both the thumbnail and fullsize image?[/QUOTE]

No, this is the full gallery script that reads the directory, loads the thumbs, and creates the link to img/photo_display.php?... (the pop-up).
[code=php]
<?PHP

//initialize variables
$photos = array(); // initialize photos array
$files = glob("th/*.jpg"); // get list of files ending in suffix .jpg
foreach($files as $value) // assign just the file name to array
{
$photos[] = array_pop(explode('/', $value));
}
$img_dir = "img/";
$thumbnail_dir = "th/";
$total_photos = sizeof($photos);
$num_columns = 3;
$num_rows = $total_photos / $num_columns;
$photos_per_page = $num_rows * $num_columns;

//check to see if the start variable exists in the URL.

//If not, then the user is on the first page - set start to 0
/*
if(!isSet($start)){
$start = 0;
}
*/

$start = 0;

//init i to where it needs to start in the photos array
$i = $start;
$prev_start = $start - $photos_per_page;
$next_start = $start + $photos_per_page;

$title = trim($photos[$i]);

if($total_photos == 0){
print("<td class="body">Kommer...</td>n");
}

else for ($row=0; $row < $num_rows; $row++){
print("<tr>n");
for ($col=0; $col < $num_columns; $col++){
if($i < $total_photos){
$title = trim($photos[$i]);
$myTitle = split('[.]', $title);
$thumbnail = $thumbnail_dir.trim($photos[$i]);
$thumb_image_size = getimagesize($thumbnail);
$image_size = getimagesize($img_dir.trim($photos[$i]));
$width = $image_size[1] + 50;
print("<td align="center" valign="middle" width="75"><a class="prodLink" onFocus="this.blur()" href="javascript:photo_open('img/photo_display.php?photo=".trim($photos[$i])."','".$image_size[0]."','".$width."');"><img border="0" src="".$thumbnail."" ".$thumb_image_size[3]."><br><br>".$myTitle[0]."<br><br></a></td>n");
} else {
print("<td width="75"><img src="../../../../img/pr/pr_spcr_trans.gif" width="75"></td>n");
}
$i++;
}
print("</tr>n");
}

//end table
?>
[/code]

This is photo_display.php, which receives the "photo" variable:
[code=php]
<html>
<head>
<title><?PHP print($photo); ?></title>
<link rel="stylesheet" type="text/css" href="../assets/css/global.css">
</head>

<?PHP
$photo_size = getimagesize("$photo");
?>

<body bgcolor="#FFFFFF" marginheight="0"
marginwidth="0" leftmargin="0" topmargin="0"
rightmargin="0">

<div align="center">

<img border="0" src="<?PHP print($photo); ?>" <?PHP print($photo_size[3]); ?> name="photo">

<br>
<br>

<a class="prodLInk" href="javascript:window.close()">lukke</a>

</div>
</body>
</html>
[/code]

Rolling over a thumb you can see that the url is correct. You can even put the address directly in the address bar - http://www.slowcocoon.com/public/ksror/tips/prod/bad/blandebatteri/img/photo_display.php?photo=opploft.jpg will work on my server, but http://www.ksrør.no/_test/tips/prod/bad/blandebatteri/img/photo_display.php?photo=opploft.jpg won't.

madddidley, where's/what's the e_error_report? In phpinfo? Couldn't find that.
Copy linkTweet thisAlerts:
@chazzyJan 20.2006 — error reporting will only tell you if something can't be called. just add [code=php]error_reporting(E_ALL);[/code] to the top of a page to see if there are any errors.

but clearly, based on the two phpinfo files, there is something installed differently between the two servers. you can only say that "this script should work on your server" if the two servers are setup the same way.
×

Success!

Help @fx2ooo spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...