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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:45:41+00:00 2026-05-15T11:45:41+00:00

Consider the following code <?php $username = root; $password = ; $host = localhost;

  • 0

Consider the following code

<?php

 $username = "root";
 $password = "";
 $host = "localhost";
 $database = "binaries";

 @mysql_connect($host, $username, $password) or die("Can not connect to database: ".mysql_error());

 @mysql_select_db($database) or die("Can not select the database: ".mysql_error());

 $id = 5;

 if(!isset($id) || empty($id)){
 die("Please select your image!");
 }else{

$query = mysql_query("SELECT * FROM tbl_images WHERE id='".$id."'");
$row = mysql_fetch_array($query);
$content = $row['imag'];
header('Content-type: image/jpg');
echo '<table><tr><td height="700" width="700">';// Line X
print $content;

echo '</td></tr></table>';//Line Y

}

?>  

When I comment the lines X and Y the image gets displayed, otherwise not.What could be the possible reason?

EDIT: After following Matt’s advice.

show.php

 echo '<table><tr><td>
  <img src="image.php"/>
  </td></tr></table>';

image.php

$query = mysql_query("SELECT * FROM tbl_images WHERE id='".$id."'");
$row = mysql_fetch_array($query);
$content = $row['imag'];
header('Content-type: image/jpg');

print $content;

Even after doing this I am not getting the expected result.

EDIT:
code of ‘image.php’ :

 <?php
  $username = "root";
  $password = "";
  $host = "localhost";
  $database = "binaries";

  @mysql_connect($host, $username, $password) or die("Can not connect to database: ".mysql_error());

 @mysql_select_db($database) or die("Can not select the database: ".mysql_error());




 $query = mysql_query("SELECT * FROM tbl_images WHERE id=5");
 $row = mysql_fetch_array($query);
 $content = $row['imag'];
 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-15T11:45:41+00:00Added an answer on May 15, 2026 at 11:45 am

    Because when the browser is told the MIME type is image/jpg, the last thing it is expecting to see is <table ...

    When you set the MIME type, you are telling the browser “I am sending you an image.” However, HTML markup is certainly not image data, so the browser doesn’t know how to render it.

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

Sidebar

Related Questions

Consider the following code: <?php $conn = mysql_connect('localhost', 'username', 'password'); mysql_select_db('database', $conn); ?> This
Consider the following php code used for HTML output: echo <div id='logo2'> <a href='if(checkLanguage())
consider the following code scenario: <?php //widgetfactory.class.php // define a class class WidgetFactory {
Consider following code: My problem is: 1) I can't seem to cast the errors
Consider the following code: $xml = <<<XML <root> <region id='thisRegion'></region> <region id='thatRegion'></region> </root> XML;
consider the following PHP code: <?php $searchsport = $_REQUEST['sport']; $sportarray = array( Football =>
Please consider the following code, <form action=index.php method=post name=adminForm enctype=multipart/form-data> <input type=hidden name=showtime[] id=showtime_1
Consider the following PHP class code class SuperIdea{ . . . static function getById($id){
I am trying to write a PHP code to query the following values. Consider
Please consider the following code: <?php class MyException extends Exception {} function global_exception_handler($exception) {

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.