Jump to content

[SOLVED] Retrieve images from database not shown in firefox but show in IE.


Recommended Posts

<?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);

?>

ah i see what youve done.

 

Please explain code, and neaten it up lol - wrap your code in

 

bb tags so its easier to read, but make sure it starts with a <?php.

 

eg:

 

[ code]

<?php

//some code

?>

[/ code]

 

---

basically, you make a php script called "getimg.php", you make it get an image from the database according to an paramters you give it via the URL, eg:

 

getimg.php?img=fduiowehr9832 could be a lovely picture of your dog.

 

After that, you ust change your current page so that ou put that link in there.

First, if the php file is creating an html page (which it seems to be) get rid of the Header("Content-type: image/jpeg"); - what you're doing at the moment is telling the browser that you're giving it an image, but then actually sending it html code with an embedded image, which are two different things.

 

Also, you don't need </img>, you just need the <img...> tag, possibly self closing (ie ends with />) depending on what html/xhtml doctype you're using.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.