Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8587437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:34:09+00:00 2026-06-11T22:34:09+00:00

This is my error: error on line 2 at column 1: Extra content at

  • 0

This is my error:

error on line 2 at column 1: Extra content at the end of the document

Below is a rendering of the page up to the first error.

I just copied the code from here.

Here’s my code:

    <?php
header('Content-type: text/xml');
function awsRequest($searchIndex, $keywords, $responseGroup = false, $operation = "ItemSearch", $pageNumber = 1){
    $service_url = "http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService";
    $associate_tag = "your-associate-tag";
    $secret_key = "YOUR_SECRET_KEY";
    $access_key = "YOUR_ACCESS_KEY";

    // build initial request uri
    $request = "$service_url&Operation=$operation&AssociateTag=$associate_tag&SearchIndex=$searchIndex&Keywords=".urlencode($keywords)."&ItemPage=$pageNumber";

    // parse request into params
    $uri_elements = parse_url($request);
    $request = $uri_elements['query'];
    parse_str($request, $parameters);

    // add new params
    $parameters['Timestamp'] = gmdate("Y-m-d\TH:i:s\Z");
    $parameters['Version'] = $version;
    $parameters['AWSAccessKeyId'] = $access_key;
    if($responseGroup){
        $parameters['ResponseGroup'] = $responseGroup;
    }
    ksort($parameters);

    // encode params and values
    foreach($parameters as $parameter => $value){
        $parameter = str_replace("%7E", "~", rawurlencode($parameter));
        $value = str_replace("%7E", "~", rawurlencode($value));
        $request_array[] = $parameter . '=' . $value;
    }
    $new_request = implode('&', $request_array);

    // make it happen
    $signature_string = "GET\n{$uri_elements['host']}\n{$uri_elements['path']}\n{$new_request}";
    $signature = urlencode(base64_encode(hash_hmac('sha256', $signature_string, $secret_key, true)));

    // return signed request uri
    return "http://{$uri_elements['host']}{$uri_elements['path']}?{$new_request}&Signature={$signature}";
}
// make the request
$xml = simplexml_load_file(awsRequest("VideoGames", "call of duty", "Images", "ItemSearch", "1"));

// now retrieve some data
$totalPages = $xml->Items->TotalPages;
echo "<p>There are $totalPages pages in the XML results.</p>";

// retrieve data in a loop
echo "<ul>\n";
foreach($xml->Items->Item as $item){
    echo "<li>".$item->ASIN."</li>\n";
}
echo "</ul>\n";
?>

I’m deploying this on AWS.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:34:10+00:00Added an answer on June 11, 2026 at 10:34 pm

    Make sure that your code editor doesn’t include a BOM in the document. I know for a fact that notepad++ and some others include this by default. If it is included, it will insert invisible characters into your document, which looks like output to the server, causing the error messages you’re seeing. Try copying and pasting your code into a NEW document that does not have the BOM.

    Creating a new php document in Dreamweaver (or other editor) WITHOUT the BOM (byte order mark) should solve the issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting this error: error on line 4 at column 1: Extra content at
i use this line of code : [self parseXMLFileAtURL:url]; And i get this error
I keep getting an expected identifier error at this line in my code =/
Saxon XSLT 2.0 processor is throwing the below error Error on line 2 column
I have this error: This page contains the following errors: error on line 15
JSLint is giving me this error: Problem at line 11 character 33: Use the
I keep getting this error in the $('#savetickets-list') line. I want to dynamically add
I am having trouble with this error message as the line it errors on
I got this error An error occurred while parsing EntityName. Line 1, position 61.
I am getting this error: Data at the root level is invalid. Line 1,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.