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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:11:44+00:00 2026-05-22T21:11:44+00:00

UPDATE: I have have ten columns in my SQL table: id, imgid, urlid, image1,

  • 0

UPDATE:

I have have ten columns in my SQL table: id, imgid, urlid, image1, image2, image3, image4, image5, and comment. Id, imgid, and urlid are int type. Image[1-5] are mediumblob type. Url and comment are text type. Imgid is the number of images uploaded (which should be 5), urlid is the number of urls submitted (which should be one right now), url holds the url, and comment holds user comments. I’d like to retrieve and output all the image data from the image columns in a row but I’m getting torn page icons. I am using a front.php to output images and a get.php to convert images to viewable format.

Here’s my front.php:

<?php

mysql_connect ("","","") or die(mysql_error());
mysql_select_db ("") or die(mysql_error());



$defaultqry = mysql_query ("SELECT * FROM dbp");

while($row = mysql_fetch_assoc($defaultqry))
{



echo ($row['image1'] != NULL) ? '<img src="get.php?id='.$row[id].'&col=1 " width="30" height="30"/> ' : '';
echo ($row['image2'] != NULL) ? '<img src="get.php?id='.$row[id].'&col=2 " width="30" height="30"/> ' : '';
echo ($row['image3'] != NULL) ? '<img src="get.php?id='.$row[id].'&col=3 " width="30" height="30"/> ' : '';
echo ($row['image4'] != NULL) ? '<img src="get.php?id='.$row[id].'&col=4 " width="30" height="30"/> ' : '';
echo ($row['image5'] != NULL) ? '<img src="get.php?id='.$row[id].'&col=5 " width="30" height="30"/> ' : '';

}
?>

Here’s my get.php:

<?php

mysql_connect ("","","") or die(mysql_error());
mysql_select_db ("") or die(mysql_error());


$query = mysql_query("SELECT * FROM dbp WHERE id = ".mysql_real_escape_string($_GET['id']));
$row = mysql_fetch_array($query);

$col = intval($_GET['col']);

if(isset($row['image'.$col]) && $row['iamge'.$col] != NULL){
    $content = $row['image'.$col];
}else{
    exit; // col is not existent, or image is empty
}

header('Content-type: image/jpg');
echo $content;
exit;




?>
  • 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-22T21:11:45+00:00Added an answer on May 22, 2026 at 9:11 pm

    first, you use a DATAbase, store data in it not files. (you should store the link/path to the files in the DB not the images itself, this only blows up your database and makes it slow) see Storing Images in DB – Yea or Nay? for more info on this topic.

    but if you want to do it this way then you will have to output the id of the row AND a column identifier like:

    echo ($row['image1'] != NULL) ? '<img src="get.php?id='.$row['id'].'&col=1 " width="30" height="30"/> ' : '';
    

    in your get.php:

    mysql_connect ("localhost","","") or die(mysql_error());
    mysql_select_db ("") or die(mysql_error());
    
    $query = mysql_query("SELECT * FROM dbp WHERE id = ".mysql_real_escape_string($_GET['id']));
    $row = mysql_fetch_array($query);
    
    $col = intval($_GET['col']);
    
    if(isset($row['image'.$col]) && $row['image'.$col] != NULL){
        $content = $row['image'.$col];
    }else{
        exit; // col is not existent, or image is empty
    }
    
    header('Content-type: image/jpg');
    echo $content;
    exit;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an UPDATE sql command that modifies a Date/Time field in a particular
If I have a script like this: $sql = SELECT * FROM table WHERE
We have a ten-year-old ASP application that we are considering planning an update for.
I have update panel that content check box, textbox, 3 DropDownList with CascadingDropDown extender.
I have scenario, I have two update panels on the page (both have update
I have some update or something that tries to run every night, and ends
I have an update query being run by a cron task that's timing out.
I have several update methods in a javascript file, used for updating my ajax
I have to update old projects at work. I do not have any experience
I have a update panel, in the update panel I have fileupload control and

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.