Hello.
I' ve tried to make database.
I made an array, and the one element is a picture (blob type).
When i call it from php code, i can't see it
Can you help me please?
I would very glad!
This is my database:
Code: Select all
use brscn;
create table alldata
(id MEDIUMINT NOT NULL AUTO_INCREMENT,
captured DATE default NULL,
img longblob default NULL,
descr varchar(200) default NULL,
fnd varchar(200) default NULL,
biopsy_rsl varchar(200) default NULL,
primary key(id));
INSERT INTO alldata VALUES (NULL, '2009-1-21', LOAD_FILE('C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/images/mammography.jpg'), 'xxxxxxxxx','xxxxx','xxxxxxxxxxxxx');Code: Select all
<?php
$con = mysql_connect("localhost:3307","root","xxxx");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("brscn", $con);
$result = mysql_query("SELECT * FROM alldata");
$row = mysql_fetch_array($result, MYSQL_ASSOC);
{
echo "Query results" . "<br />". "--------------------<br />" ;
echo $row['id'] . " | ". $row['captured'] . " | " ;
;
$image = imagecreatefromstring($row['img']); //this is the pic
if ($image !== false) {
header('Content-Type: image/jpeg');
imagegif($image); //output the image
imagedestroy($image); //free up memory
}
else {
echo 'An error occurred.';
}
echo " | " . $row['descr'] . " | " . $row['fnd'] . " | " . $row['biopsy_rsl'];
echo "<br />";
}
mysql_close($con);?>pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: