Forum Moderators: coopster
The problem came when i stored the images in mysql datebase, the image field have longblob type. Some of images not displayed. Why?
I can't understand the reason. Because when user visite images original address they view it. Before storing images in mysql datebase the images stored in file system and viewed normally without any problems.
here the code of showing image from mysql datebase.
1. <?php
header("Content-type: image/jpeg");
$imageID=$_GET['imageID'];
mysql_connect("dbhost","dbuser","dbpass");
mysql_select_db("dbname");
$query= "select * from tablename where imageID = $imageID";
$res=mysql_query($query) or die(mysql_error());
$rows=mysql_fetch_array($res);
echo $r ows['Image'];
mysql_close();
?>
2. here from where 1. called.
<html>
<head>
</head>
<body>
<?php
for($i=0;$i<10;$i++)
echo "<img src='1.?imageID=$i'>\n ";
?>
</body>
</html>
all files when stored in file system was viewd normally.
What the problem? please tell me :((((((
the image field have longblob type
Does this mean that you store the picture data in the database?
You should copy the picture in one of our folder and then in the database, only the WIDTH, the HEIGHT and the NAME is required (so non longblob require).
Usually I generate the picture name by creating an unique variable.
PICTURE NAME - pic_125de6585de14tr3t5
WIDTH - 470
HEIGHT - 450
If you know that your pictures are in a folder called "GDPIC" for example, then the URL is "GDPIC/[PICTURE_NAME].jpg"
You can also create another folder called "GDPIC_SMALL" where you put thumbnail size pictures and the URL is "GDPIC_SMALL/[PICTURE_NAME].jpg"
Hope this help
Then I don't think it is the best way to store pictures in database, you better save your pictures in a folder and store only the "width", "height", "alt" and "name" in the database.
I can't help you much because I don't store picture your way, nonetheless I suspect it is a string conversion problem.
May be when storing data in db, some special characters are changed! Check the code source to see which datas are retrieve and compare it with the original.
Otherwise, tell us a bit more about what you get (warning message, etc.).