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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:35:02+00:00 2026-05-31T02:35:02+00:00

I am trying to do something I know is probably simple, but I am

  • 0

I am trying to do something I know is probably simple, but I am having the worst time.
I have functioning so far:
1.Script to upload image files to server
2. write the image file names to the database
3. I want to retrieve the image filename from the db and add it to the img src tag
here is my retrieval script

 <?php

 $hote = 'localhost';
 $base = 'dbasename';
 $user = 'username';
 $pass = '******';
 $cnx = mysql_connect ($hote, $user, $pass) or die(mysql_error ());
 $ret = mysql_select_db ($base) or die (mysql_error ());
 $image_id = mysql_real_escape_string($_GET['ID']);
 $sql = "SELECT image FROM image_upload WHERE ID ='$image_id'";
 $result = mysql_query($sql);
 $image = mysql_result($result, 0);

 header('Content-Type: text/html');
 echo '<img src="' $image'"/>';

 ?>

I was trying to pass the Value through image.php?ID=2 but no luck

The PHP script successfully returns the filename, but I cannot for the life of me get it to print it to the html

Any suggestions, please and thank you very much 🙂

OK, it does return the proper tag, but now it seems as though the script doesnt run to generate the tag.
I have tried two ways:

<div class="slides">
    <div class="slide">
        <div class="image-holder">
            <?php
    include ("image.php?ID=2");
    ?>
        </div>

and:

 <img src="image.php?ID=2" alt="" />     

but neither one will insert the filename…
I need to identify each img src by the primary key, so I was passing it the ID from each image src location
but alas, my PHP ninja skills need to be honed.

Just to clarify: I am uploading images to the server, recording the filenames in a DB and calling that filename in an HTML doc…there are several in each one so I need to pass the ID (i.e. 1,2,3 ) to correspond to the primary key in the table.
But I cant get the script to process the tag first.
If I go to view source, I can click the script and get the proper result…

Thanks again, you guys and girls are very helpful

  • 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-31T02:35:03+00:00Added an answer on May 31, 2026 at 2:35 am

    You can do it as you did but you had the single quotes in twice, (unless you were meaning to use concatenation – which is unnecessary – if you want this see the other answer).

    echo "<img src=\"$image\"/>";
    

    Or the longer form with braces if you need to embed inside text.

    echo "<img src=\"${image}\"/>";
    

    I’d recommend using heredoc syntax for this if you’re doing lots of HTML. This avoids the need to have lots of echo lines.

    echo <<< EOF
       <div class="example">
       <img src="$image" />
       </div>
    EOF;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know something about Java but completely new to Enterprise Java. I'm trying my
I know very little about JavaScript but despite this I'm trying to cobble something
I am trying something very simple, but for some reason it does not work.
This is probably something simple but I'm scratching my head over easing with the
I'm trying to fix something in some Objective C++ (?!) code. I don't know
I'm trying something like this, but this example does not work. jsObj = {};
actually I thought I was trying something really simple. ControllerClassNameHandlerMapping sounded great to produce
I know this probably is not the easiest thing to do, but I am
I'm sure this is something very simple that I'm screwing up, but here goes:
So this is probably an easy thing that I'm trying to do but I'm

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.