as for using $_SERVER['HTTP_HOST'] I would use $_SERVER['DOCUMENT_ROOT']
Main Topics
Browse All TopicsHello everybody, I recently pulled some code that I wrote for a site on a Linux server and tried to use it for a site on a Windows server. As a quick solution for a friends site, its a bunch of html with the php in the middle that is supposed to display a few images as pop-up links in a table. The strange thing is the that not only does the code not work and provides no error messages, but it prevents any of the html from being parsed, outputting nothing but the open and closed html and body tags. Heres the code:
<html>
<body>
<!----------- html header --------->
<?php
function makeThmb ($neWdth, $file) {
$origImgPth = $_SERVER['HTTP_HOST']."/ga
$thmbImgPth = $_SERVER['HTTP_HOST']."/ga
if (!file_exists($thmbImgPth)
$quality = "50";
list($origWdth, $origHght, $imgTpe) = getimagesize($origImgPth);
//$imgTpe = ($imgTpe === "1" ? "gif" : ($imgTpe === "2" ? "jpg" : ""));
$ratio = ($origWdth / $neWdth);
$newHght = round($origHght / $ratio);
switch ($imgTpe) {
case "2": //jpg
$image_p = imagecreatetruecolor($neWd
$image = imagecreatefromjpeg($origI
imagecopyresampled($image_
imagejpeg($image_p, $thmbImgPth, $quality);
return ("true");
break;
default: //not jpg
return ("false");
break;
}
} elseif (file_exists($thmbImgPth))
return ("true");
} else {
return ("false");
}
}
$folder = "/gallery/";
if ($handle = opendir($folder)) {
/* loop over the directory. */
$images = array();
$arr = 0;
while (false !== ($file = readdir($handle))) {
$fileext = substr(strrchr($file, "."), 1);
if(strtolower($fileext) == "jpg" || strtolower($fileext) == "gif"){
$images[$arr] = $file;
$arr++;
}
}
closedir($handle);
$thmbNail = "";
$content = "<table border=\"0\" cellpadding=\"3\" cellspacing=\"3\" align=\"center\">\n<tr>\n<
$cnt = 0;
for ($i=0; $i<=ceil($arr/4); $i++) {
$content .= "<tr>\n";
for ($x=0; $x<=4; $x++) {
if (isset($arr[$cnt]) {
//create thumb
$thmbNail = (makeThmb("100", $images[$cnt]) === "true" ? "gallery/thmbs/".$images[$
//display thmb
$content .= "<td><a class=\"press\" href=\"#\" onclick=\"window.open('gal
$cnt++;
} else {
$content .= "<td> </td>\n";
$cnt++;
}
}
$content .= "</tr>\n";
}
$content .= "</table>";
} else {
$content = "Images Coming Soon";
}
echo $content;
?>
<!------- html footer ---------->
</body>
</html>
I know the opendir function doesn't work. I learned this by completely commenting out the makeThmb function, which seems to be the reason none of the html is parsed. Any help would be greatly appreciated.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Ok, I changed the forward slashes to backward slashes (not including the ones used for the html) and http_host is now document_root. I am still getting the same results. I looked over the functions I'm using on php.net and I didnt see any mention of different functionality on windows systems. I made sure to set the folder permissions to allow all... Can you think of anything else it might be?
Are the PHP versions the same?
I would probably put in the script some debug info to check what is really happening (as compared to "what I think should happen")
My initial candidates would be a display of $quality (which will prove that we entre the {} and $imgType, but obviously there are some other good variables to display
btw when I copied and pasted your above code PHP came up with parse errors. The following lines...
$origImgPth = $_SERVER['HTTP_HOST']."/ga
should be..
$origImgPth = $_SERVER['HTTP_HOST']."/ga
if (isset($arr[$cnt]) {
should be..
if (isset($arr[$cnt])) { <-- added missing )
Thanks Cryptic, It looks like the host has errors turned off and after setting the errors to all in the script I was able to figure out all the issues. I didnt think of setting the errors to all until you pointed out the parse errors.
Strange thing though, document_root brings up an error saying that its an undefined index. I'm using the complete path for now, but I'd like to let the server fill in the path. Any suggestions?
CrYpTiC MauleR is correct. When you add a period between different variables or strings it tells PHP to not treat them all as one, but to parse each string/variable seperately. The period seperates the variables and strings. As I haven't been following this thread, I'm not sure if that's your only problem, but it definently would be a start.
Business Accounts
Answer for Membership
by: CrYpTiC_MauleRPosted on 2005-08-22 at 08:49:19ID: 14725286
you need to not use / in directories but use \\
like..
Linux : /foldername/images
Windows \\foldername\\images