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

  • Home
  • SEARCH
  • 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 7612603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:57:20+00:00 2026-05-31T01:57:20+00:00

I am retrieving an array of book objects with attributes like title,isbn and image.

  • 0

I am retrieving an array of book objects with attributes like title,isbn and image. When I wish to display only labels using for loop it is displaying all entries. But when I try to display image, it only displays one. Also when I try to display both title and image, it says can

Warning: Cannot modify header information - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/BookStore/BooksResult.php:14) in /Applications/XAMPP/xamppfiles/htdocs/BookStore/BooksResult.php on line 15.

Below is the code.

foreach($booksArr as &$book)
{
    $content = $book->Image;
    $title=$book->s_Title;                  
    echo $title;
    header('Content-type: image/jpg');
    {
        echo $content;
    }
}
  • 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-05-31T01:57:21+00:00Added an answer on May 31, 2026 at 1:57 am

    The “Cannot modify header information…” problem is here:

    header('Content-type: image/jpg');
    

    Your PHP script is outputting HTML. You cannot change the content type of the output mid-stream. Instead, you should output an <img> tag that points to the image location.

    UPDATE BASED ON COMMENT DATA:

    If you need to serve your images as blobs from the database, you will need to create a separate script to fetch the images. First modify this one to reference the new script by creating an <img> tag with a src attribute that contains the path to your image-fetching script and the image ID:

    <img src="/path/to/your/new/script.php?id=<?php echo $row_id; ?>" />
    

    Substitute $row_id with the field data that uniquely identifies a book in your database.

    Next, create the new image fetching script. It will contain three elements:

    1. A line to get the id from the GET request:
      $id = $_GET[‘id’];

    2. An SQL statement to fetch the image blob based on the ID. (Remember to sanitize your input!)

    3. A header() statement like the one you used in your original script

    After the header() line, just output the blob, and your image will be displayed.

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

Sidebar

Related Questions

I can grab a random value from an array-like structure by retrieving a random
I'm retrieving an array of objects from a hidden html input field. The string
I have a PHP array that I'd like to duplicate but only copy elements
I need help in retrieving a JSON object and parsing the array into my
When retrieving objects from an NSMutableArray in cocoa-touch is the below code ok? Should
I am retrieving 3 fields from a database, and by default, only the username
I am retrieving a byte array of a pictureStream from a .net webservice. the
I am converting images to byte array and storing in a text file using
When retrieving data from MySQL, the PHP array output has both numeric and name
I have a problem with retrieving data from a database using PHP statements. At

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.