converting BLOB to jpeg MySQL/PHP

maybe, but the same code works when its connected to another table in the same database, an outline of the image appears for about 3 seconds and then disappears. any ideas?
 
tuckenator said:
maybe, but the same code works when its connected to another table in the same database, an outline of the image appears for about 3 seconds and then disappears. any ideas?
Right click the outline and go to properties. What's in the source?
 
it looks like you're trying to combine 2 scripts into 1. you cannot do that. :p

using my example above, image.php can only display one image from the data base at a time. you can call it multiple times from a separate script (list.php in my example) to display multiple images. :)
 
i'm only trying to display a single image though, i think its the

Code:
<img src="download.php?id=
that cannot connect to more than one table? as it is displaying the images in one table but not the other, even though the connections to the tables are on different php pages.

when i go to the properties of the outline of the image it doesnt link to the image id, just
Code:
download.php?id=
making the file type unrecognisable, so it cant be displayed.

??
 
Last edited:
edit: oops. misreading your script. i tried it on my script and it works... :p

edit2: here's my working script named view.php

Code:
<?

mysql_connect('localhost', 'root', 'ocuk') or die (mysql_error());
mysql_select_db('test');

if(isset($_GET['id']))
{
	$id      = $_GET['id'];
	$query   = "SELECT content FROM blob1 WHERE id = '$id'";
	$result  = mysql_query($query);
	list($content) = mysql_fetch_array($result);
	header("Content-type: image/jpg");
	echo $content;
	mysql_close();
	exit;
}

$query  = "SELECT id FROM blob1";
$result = mysql_query($query) or die(mysql_error);
if(mysql_num_rows($result) == 0) {
	echo "Database is empty <br>";
} else {
	while(list($id) = mysql_fetch_array($result)) {
		echo '<p><img src="view.php?id='.$id.'"></p>';
	}
}
mysql_close();
?>

i've cut the crap. no need to fetch more than we need from the db. :)

edit3: you've missed

header("Content-type: image/jpg");

can't believe i missed that. you need that. i have no idea what your headers do...
 
Last edited:
PHP:
<?
include 'db.php';
   dbConnect('epicfx00_sms');

if(isset($_GET['id']))
{
$id      = $_GET['id'];
$query   = "SELECT content FROM userimage WHERE userid = '$userid'";
$result  = mysql_query($query);
list($content) = mysql_fetch_array($result);
header("Content-type: image/jpg");
echo $content;
exit;
}

$query  = "SELECT id FROM userimage";
$result = mysql_query($query) or die(mysql_error);
if(mysql_num_rows($result) == 0) {
echo "Database is empty <br>";
} else {
while(list($id) = mysql_fetch_array($result)) {
echo '<p><img src="main.php?id='.$id.'"></p>';
}
}
?>

dbexample.gif


still nothing, the image doesnt even try to appear. RAGE.com
 
Back
Top Bottom