phpcodeigniterzend-frameworkinternal-server-error

Zend Service Amazon - Internal Server Error - Works on localhost?


I am having a really frustrating problem with my Zend Service Amazon package integrated into my codeigniter framework. The library works perfectly fine in my localhost but when I try it from the live site it doesn't work, it gives me an internal server error. Why could this be?

The error in the PHP log is:

[22-Nov-2012 21:29:02] PHP Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home5/tradejun/public_html/application/controllers/dev.php on line 30 [22-Nov-2012 21:29:02] PHP Parse error: syntax error, unexpected T_STRING in /home5/tradejun/public_html/application/controllers/dev.php on line 30

Line 30:

$autoloader = new Zend\Loader\StandardAutoloader(array(

Here is my controller function:

public function amazon2($isbn)    {
    set_include_path(get_include_path() . PATH_SEPARATOR . 'application/libraries/Amazon');
    require_once 'Zend/Loader/StandardAutoloader.php';

    $autoloader = new Zend\Loader\StandardAutoloader(array(
        'namespaces' => array(
            'Zend'        => dirname(__FILE__) . '/Zend',
            'ZendRest'    => dirname(__FILE__) . '/ZendRest',
            'ZendService' => dirname(__FILE__) . '/ZendService',
        ),
        'fallback_autoloader' => true));

    $autoloader->register();

    $tag       = 'colleg-21'; // replace with your Amazon app ID
    $appId     = '[appid]'; // replace w/ your access key from https://portal.aws.amazon.com/gp/aws/securityCredentials
    $secretKey = '[secretkey]';
    $query  = new ZendService\Amazon\Query($appId, 'UK', $secretKey);
    $item   = $query->itemLookup($isbn,
        array('SearchIndex'   => 'Books',
            'AssociateTag'  => $tag,
            'IdType'        => 'ISBN',
            'ResponseGroup' => 'Large',));
    $item->smallImageAddress = $item->SmallImage->Url->getImageAddress();
    $item->mediumImageAddress = $item->MediumImage->Url->getImageAddress();
    $item->largeImageAddress = $item->LargeImage->Url->getImageAddress();
    $data['item'] = $item;
    $this->load->view('development/amazon',$data);
}

Can anyone provide any suggestions or possible solutions?

Points


Solution

  • It must be an old version of php - doesn't support namespaces. You need php 5.3 for namespaces. You'll need to upgrade.

    Edit: corrected version number required for namespaces; only need 5.3, not 5.4. Thanks, E_p