Forum Moderators: coopster

Message Too Old, No Replies

Please help with php T STRING problem

         

optimalwebsite

10:04 am on Apr 9, 2008 (gmt 0)

10+ Year Member



Hi all,

Any help appreciated!

We have a website which we are in the process of moving server, but we can't get it to run :-(

The error message states

"PHP Parse error: parse error, unexpected T_STRING in e:\domains\gallery2c.com\wwwroot\media.php on line 9"

The index.php code is

<?php
// $Id: index.php 168 2006-12-21 12:59:12Z david $
require_once '../lib/OrientationMapper.php';
require_once '../lib/ProductMapper.php';
require_once '../lib/ArtistMapper.php';
require_once '../lib/SubjectMapper.php';

require_once '../lib/Gallery.php';

$smarty = new Smarty_Gallery();

$artist = ArtistMapper::findFeaturedArtist();
if (is_object($artist)) {
$smarty->assign('artist', $artist);
}
$products = ProductMapper::findFeaturedProducts(1);
$featured = array();
$offset = 0;
foreach ($products as $product) {
$featured[$offset]['product'] = $product;
$featured[$offset]['artist'] = ArtistMapper::findArtist($product->artist);
$offset++;
}
$smarty->assign('featured', $featured);
$smarty->assign('tpl_name', 'home');
$smarty->assign('meta_title', 'photographers gallery bristol, photographic art bristol, image library bristol, picture gallery');
$smarty->assign('meta_desc', 'photographers gallery bristol, photographic art bristol, image library bristol, picture gallery, photographic pictures ');
$smarty->assign('meta_keys', 'photographers gallery bristol, photographic art bristol, image library bristol, picture gallery, photographic pictures');
$smarty->display('default.tpl');
?>

and the media.php code is:

<?php
// $Id: media.php 112 2006-12-15 09:11:10Z david $
require_once '../lib/ProductMapper.php';

$product = ProductMapper::findProduct($_GET['p']);
if (is_object($product) == false)
return;

$cache_file = 'media/cache/' . $_GET['p'] . $_GET['i'] . '.jpg';
$ctime = time();
$ftime = filectime($cache_file);
$dtime = $ctime - $ftime;
// Use the cache on 95% of occasions, where the file is newer than 24 hours old.
if (file_exists($cache_file) && rand(1, 100) > 95 && $dtime < 86400) {
header("Content-Type: image/jpeg");
readfile($cache_file);
} else {
switch ($_GET['i']) {
case "f":
$url = $product->image_featured;
++$product->impressions_b;
break;
case "n":
$url = $product->image_full;
++$product->impressions;
break;
case "t":
$url = $product->image_thumbnail;
++$product->impressions_c;
break;
}
ProductMapper::updateProduct($product);
if (isset($url)) {
$path = '../srv/uploads/photographs/';
if (file_exists($path . $url)) {
header("Content-Type: " . mime_content_type($path . $url));
$im_meta = getimagesize($path . $url);
if ($im_meta[2] == IMG_JPG) {
$im = imagecreatefromjpeg($path . $url);
imagejpeg($im, $cache_file);
imagejpeg($im);
} else {
readfile($path . $url);
}
}
}
}
?>

There are other php files too, any help appreciated. If I need to post more code please let me know!

Warm Regards,

Joel

[edited by: jatar_k at 12:46 pm (utc) on April 9, 2008]
[edit reason] no urls thanks [/edit]

jatar_k

12:48 pm on Apr 9, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld optimalwebsite

since the error is coming from media.php can you post the first 9 lines of that file

optimalwebsite

1:01 pm on Apr 9, 2008 (gmt 0)

10+ Year Member



Its above!

jatar_k

4:09 pm on Apr 9, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



heh, well another strike against code dumps, I pasted the whole thing and never even noticed the second file since the top said index.php

so these lines

<?php
// $Id: media.php 112 2006-12-15 09:11:10Z david $
require_once '../lib/ProductMapper.php';

$product = ProductMapper::findProduct($_GET['p']);
if (is_object($product) == false)
return;

$cache_file = 'media/cache/' . $_GET['p'] . $_GET['i'] . '.jpg';

I can't see an error actually, anyone else?

Little_G

4:39 pm on Apr 9, 2008 (gmt 0)

10+ Year Member



Hi,

It might be a problem with the return statement, you aren't inside a function, I think you want die instead?

Andrew

[edit]
Sorry, I don't think that is wrong, ignore me!
[/edit]

[edited by: Little_G at 4:54 pm (utc) on April 9, 2008]

jatar_k

4:56 pm on Apr 9, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



hmmm, you might be onto something

if return isn't accepted there, which you're right, it isn't, then maybe the parser sees that if as unclosed

worth a try

Little_G

5:00 pm on Apr 9, 2008 (gmt 0)

10+ Year Member



Hi,

I was just reading the docs and apparently you can use a return in a global scope to quite the script, which I never knew before! So I'm not sure if that the error or not.
[php.net...]

Andrew

jatar_k

5:32 pm on Apr 9, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



one of those behaviours I see no point to, though for a prepended/appended file it would be ok, strange in the main script

be that as it may I still don't see anything else, I would comment out that whole if just to test it