Retrieve images from database not shown in firefox.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
asad_black
Forum Newbie
Posts: 20
Joined: Wed Feb 11, 2009 1:59 am

Retrieve images from database not shown in firefox.

Post by asad_black »

Code: Select all

<?php
Header("Content-type: image/jpeg");
$var = @$_GET['q'] ;
$trimmed = trim($var);
$con = mysql_connect("localhost","sample","sample");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("sample", $con);
$sql = mysql_query("SELECT * FROM links");
 
while($row = mysql_fetch_array($sql))
{
echo $row['title'];
echo "<center><img height='200' width='200' src='".$row['image']."'></img><br><br><br></center>";
//echo "<img src='".$row['imgdata']."'>";
echo $row['link'];
echo "<br />";
}
mysql_close($con);
?>
its work correctly on IE but in fire fox it shows the path of the PHP file...!

Output in firefox = http://localhost/mywork/asad_black/view_records.php
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Retrieve images from database not shown in firefox.

Post by Christopher »

Please use

Code: Select all

tags when posting code. And no one else can see your 'localhost' server.

What does the generated <img> tag URL look like? Is is a relative path or have 'http://' in the URL?
(#10850)
bugrush
Forum Newbie
Posts: 15
Joined: Tue Dec 16, 2008 3:00 pm

Re: Retrieve images from database not shown in firefox.

Post by bugrush »

you are setting content type to image/jpeg and outputting html
asad_black
Forum Newbie
Posts: 20
Joined: Wed Feb 11, 2009 1:59 am

Re: Retrieve images from database not shown in firefox.

Post by asad_black »

give me a solution
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Retrieve images from database not shown in firefox.

Post by John Cartwright »

No please? How impolite...

Anyhow.. remove the header() call. You are setting the content type to something other than what your outputting (as bugrush pointed out)
asad_black
Forum Newbie
Posts: 20
Joined: Wed Feb 11, 2009 1:59 am

Re: Retrieve images from database not shown in firefox.

Post by asad_black »

thankx for the participation my problem has been solved...!

by removing header content...!
Post Reply