Jump to content

Displaying images from mysql


justcraig

Recommended Posts

Im a beginner not completely useless but entirely self taught via trial and error. I am having an issue i am building a website at the moment and i have the news article table. In the table i have 5 rows of longblob binary image data. Now i get 1 of the five rows to display but the rest give me headers already sent errors. i was wondering if somebody more skilled then me could help me figure out what im doing wrong.
Code below:
<?php require_once('../Connections/gyfinal.php'); ?>
<?php

$colname_articles = "-1";
if (isset($_GET['article_id'])) {
  $colname_articles = (get_magic_quotes_gpc()) ? $_GET['article_id'] : addslashes($_GET['article_id']);
}
mysql_select_db($database_gyfinal, $gyfinal);
$query_articles = sprintf("SELECT image1, image2, image3, image4, image5 FROM news_article WHERE id = %s", $colname_articles);
$articles = mysql_query($query_articles, $gyfinal) or die(mysql_error());
$row_articles = mysql_fetch_assoc($articles);
$totalRows_articles = mysql_num_rows($articles);

header("Content-type: image/jpeg") ;
echo $row_articles['image1'];
echo $row_articles['image2'];
echo $row_articles['image3'];
echo $row_articles['image4'];
echo $row_articles['image5'];

mysql_free_result($articles);
?>
This displays the first image (image1) perfectly but the rest give me an error that the headers have been sent already.
Any help would be appreciated.
If you need any more info please reply with what you need
Link to comment
https://forums.phpfreaks.com/topic/35153-displaying-images-from-mysql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.