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 9061217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:25:45+00:00 2026-06-16T15:25:45+00:00

I am doing PHP for the first time and research about this but not

  • 0

I am doing PHP for the first time and research about this but not joy. Basically, i am trying to get the images from my PHPMyAdmin database and upload it to a webpage that i have created. All the heading and texts are being displayed as intended apart from the image.

Code in which i am getting the images from database

    <?php
        include 'config.php';
        include 'opendb.php';
        $getdestinationdetails = mysql_query("SELECT *
        FROM tbldestinations
        WHERE destinationid = $_GET[destinationid]");
        while($row = mysql_fetch_array($getdestinationdetails))
        {
        echo "<h1>Visit " . $row['destinationname'] . "</h1>".
        "<imgsrc = 'images" . $row['destinationimage'] . "' />"  .
        "<br />
        <br />" .
        $row['destionationdesc'] .
        "<br />
        <br />
        Our holidays include:
        <ul>
            <li>Luxury coach travel from Shipley Town Centre</li>
            <li>Bed and Breakfast at a top hotel</li>
            <li>Free tea and coffee on board your coach</li>
            <li>The services of an experienced courier</li>
            <li>Free complimentary glass of champagne upon arrival at your hotel</li>
        </ul>
        <center><h2>Don't delay, book today!</h2></center>";
        }
        include 'closedb.php';
?>

I tried all the experiments but all in vain. any tips or suggestions would be really appreciated. Thanks in advance

  • 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-16T15:25:46+00:00Added an answer on June 16, 2026 at 3:25 pm

    If the actual image is stored in the database, you have two options:

    1. Make another script that is designed to just load images from the database. In this script, you will set the header('Content-Type: image/jpeg') (or whatever the type of image that you will display is. Then, you will output the content. This option might not be as preferred, as it takes an extra call to the database (http://stackoverflow.com/questions/5525830/displaying-an-image-stored-in-a-mysql-blob)
    2. A little more risky, for browser compatibility is to base64 encode it and output it directly into the image tag. (http://stackoverflow.com/questions/1207190/embedding-base64-images)

    Either option, you will need to still have an <img /> tag on your main page. Option 1 requires a src attribute pointing to the script, including whatever identifiers needed to look up the image in the database (but being very careful about XSS). Option 2 outputs it directly into the image tag, so that is preferable in some respects as well

    If it is just a link to an image:

    Your above code should work fairly fine, except with this modification:

    echo "<h1>Visit " . $row['destinationname'] . "</h1>".
         "<img src=\"images/" . $row['destinationimage'] . "\" />"  .
    ...
    

    Edit:

    What I would do, which would be the easiest is this: in your php file, output your image (assuming it is a jpg), like this:

    ...
    echo '<img src="data:image/jpeg;base64,' . base64_encode($row['destinationimage']) . '" />';
    ...
    

    The above will actually put the image into the image tag itself, instead of downloading across the internet. I think the hangup here is the fact that you are seeing the image in PHPmyAdmin. When you see the image there, there really is no way to get it out of PHPmyAdmin. I haven’t tried it myself, but I would assume that they are doing something similar to what I show you above – just displaying the image in the HTML tag.

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

Sidebar

Related Questions

Long time mysql/php user, first time Drupal user. Actually, I'm not doing the Drupal
This is the first time I use mod_rewrite and I can't get it to
I am trying out PDO in PHP for the first time. I thought that
This is my first time doing an FLASH form validation and I'm new to
I have never collected DOB before. This is the first time i am doing
HI, this is my first time doing this. I've read The definitive guide to
I have coded in PHP but today for the first time I needed to
long time listener. First time caller... Not strictly a PHP question as it involves
I am doing OO javascript for the first time. I have read about inheritance
I'm trying to get a new to fire the first time in my loop

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.