500尝试运行php脚本时出现内部服务器错误


500 Internal server error when I try to run my php script

当它尝试运行这个php脚本时

<?php
require_once 'TesseractOCR/TesseractOCR.php';
require_once 'aws_signed_request.php';
define("public_key", "****");
define("private_key", "****");
define("associate_tag", "****");
if (isset($_GET['ASIN']))
{
$ASIN = $_GET['ASIN'];
$link = "http://charts.camelcamelcamel.com/us/" . $ASIN . "/sales-rank.png?force=1&zero=0&w=400&h=400&legend=1&ilt=1&tp=1m&fo=0&lang=en";
$localurl = "../imgs/" . $ASIN . ".png";
$slocalurl = "../imgs/" . $ASIN . "-2.png";
$highrank = createSession($link, $localurl, 1);
$lowrank = createSession($link, $slocalurl, 2);
$info = ping_amazon($ASIN);
generate_response($info[0], $info[1], $lowrank, $highrank);
}
else
{
echo ('NO-ASIN');
}
function resize_and_crop($original_image_url, $thumb_image_url, $thumb_w, $thumb_h, $quality = 75)
{
$original = imagecreatefrompng($original_image_url);
if (!$original) return FALSE;
list($original_w, $original_h) = getimagesize($original_image_url);
$thumb_w_resize = $thumb_w;
$thumb_h_resize = $thumb_h;
if ($original_w > $original_h)
    {
    $thumb_h_ratio = $thumb_h / $original_h;
    $thumb_w_resize = (int)round($original_w * $thumb_h_ratio);
    }
  else
    {
    $thumb_w_ratio = $thumb_w / $original_w;
    $thumb_h_resize = (int)round($original_h * $thumb_w_ratio);
    }
if ($thumb_w_resize < $thumb_w)
    {
    $thumb_h_ratio = $thumb_w / $thumb_w_resize;
    $thumb_h_resize = (int)round($thumb_h * $thumb_h_ratio);
    $thumb_w_resize = $thumb_w;
    }
$thumb = imagecreatetruecolor($thumb_w_resize, $thumb_h_resize);
if (!imagecopyresampled($thumb, $original, 0, 0, 0, 0, $thumb_w_resize, $thumb_h_resize, $original_w, $original_h)) return FALSE;
$final = imagecreatetruecolor($thumb_w, $thumb_h);
$thumb_w_offset = 0;
$thumb_h_offset = 0;
if ($thumb_w < $thumb_w_resize)
    {
    $thumb_w_offset = (int)round(($thumb_w_resize - $thumb_w) / 2);
    }
  else
    {
    $thumb_h_offset = (int)round(($thumb_h_resize - $thumb_h) / 2);
    }
if (!imagecopy($final, $thumb, 0, 0, $thumb_w_offset, $thumb_h_offset, $thumb_w_resize, $thumb_h_resize)) return FALSE;
if (!imagepng($final, $thumb_image_url, $quality)) return FALSE;
return TRUE;
}
function createSession($link, $localurl, $imgtype)
{
copy($link, $localurl);
if ($imgtype == 1)
    {
    $sourceX = 125;
    $sourceY = 388;
    $sourceWidth = 110;
    $sourceHeight = 12;
    $destWidth = 110;
    $destHeight = 12;
    $destX = 0;
    $destY = 388;
    }
  else
    {
    $sourceX = 235;
    $sourceY = 388;
    $sourceWidth = 110;
    $sourceHeight = 12;
    $destWidth = 110;
    $destHeight = 12;
    $destX = 0;
    $destY = 388;
    }
$image = imagecreatefrompng($localurl);
$newImage = imagecreatetruecolor($sourceWidth, $sourceHeight);
$sNewImage = imagecreatetruecolor($sourceWidth, $sourceHeight);
imagecopyresampled($newImage, $image, 0, 0, $sourceX, $sourceY, $destWidth, $destHeight, $destWidth, $destHeight);
imagepng($newImage, $localurl, 9);
resize_and_crop($localurl, $localurl, $destWidth * 2, $destHeight * 2, 1);
imagedestroy($image);
imagedestroy($newImage);
$tesseract = new TesseractOCR($localurl);
$text = $tesseract->recognize();
$text = str_replace(" ", "", current(explode("(", $text)));
$text = str_replace(" ", "", current(explode("{", $text)));
$text = preg_replace('/[^0-9]+/', '', $text);
return $text;
}
function ping_amazon($ASIN)
{
$params = array(
    "Operation" => "ItemLookup",
    "IdType" => "ASIN",
    "ItemId" => $ASIN,
    "ResponseGroup" => "SalesRank,ItemAttributes"
);
$url = encode_info("com", $params, public_key, private_key, associate_tag);
$xml = simplexml_load_file($url);
$title = (string)$xml->Items->Item->ItemAttributes->Title;
$salesrank = (string)$xml->Items->Item->SalesRank;
$info = array(
    $title,
    $salesrank
);
return $info;
}
function generate_response($title, $salesrank, $lowrank, $highrank)
{
$average_rank = intval(($highrank + $lowrank) / 2));
header("Content-type: text/xml");
echo "<?xml version='1.0' encoding='UTF-8'?>'n";
echo "<Information>'n";
echo "<Title>" . $title . "</Title>'n";
echo "<SalesRank>" . $salesrank . "</SalesRank>'n";
echo "<LowRank>" . $lowrank . "</LowRank>'n";
echo "<HighRank>" . $highrank . "</HighRank>'n";
echo "<AverageRank>" . $average_rank . "</AverageRank>'n";
echo "</Information>";
}
?>

当我用xampp在电脑上测试它时,它是有效的,但当我试图在服务器上运行它时,却不起作用。我已经安装了Tesseract和ImageMagick,我所有的php文件都设置为775,但我仍然会收到一个内部服务器错误,我觉得这是因为我缺少依赖项,但我真的不知道是哪一个。谢谢你的帮助!

问题:我正试图找出如何修复我的内部服务器错误

PHP分析错误:语法错误,test.PHP中第134行出现意外的")"

这条线上有一个额外的)

$average_rank = intval(($highrank + $lowrank) / 2));

应该是

$average_rank = intval(($highrank + $lowrank) / 2);