Page 1 of 1

image manipulation php mysql blob type

Posted: Mon May 30, 2011 3:30 pm
by patraghost
hello there! i got a question about blob mysql data.i have a button and on buttonclick i want to open a popup (and passing date parameter) and show some details and display a photo.if i try
[syntax=php]<?php
if (isset($_GET['p'])){
$temp_date=$_GET['p'];
echo "DATE : $temp_d <br>";
$connect=mysql_connect("localhost","user","pass")
or die ("Check your server connection");
$db_found = mysql_select_db("mydb", $connect);
$SQL = "SELECT * FROM mytable
WHERE date =$temp_d";
$result = mysql_query($SQL);
$row=mysql_fetch_array($result);
echo "Details: $row[details]<br>";
$content = $row['image'];
header('Content-type:image/jpg');
echo $content;
} ?>
[/syntax]
its not working.in firefox its shows the name of the script+parameter and in IE opens a download box
If i try
[syntax=php]<?php
$connect=mysql_connect("localhost","user","pass")
or die ("Check your server connection");
$db_found = mysql_select_db("mydb", $connect);
$SQL = "SELECT * FROM mytable
WHERE id=1";
$result = mysql_query($SQL);
$row=mysql_fetch_array($result);
$content = $row['image'];
header('Content-type:image/jpg');

} ?>[/syntax]
its shows my stored image.how to pass the parameter and show the results to ? i dont know how thats possible but if i dont put
echo $content; i got my data (from other echoes) .how to have both image echo and details echo ?? tnx in advance

Re: image manipulation php mysql blob type

Posted: Mon May 30, 2011 4:01 pm
by jacek
Storing images this way is basically terrible. you should give up on this method develop something that uses files.

Re: image manipulation php mysql blob type

Posted: Mon May 30, 2011 10:28 pm
by patraghost
but generally its kind of convinient to me for the specific site i develop ! can you help me pls ?

Re: image manipulation php mysql blob type

Posted: Tue May 31, 2011 11:04 am
by jacek
It can't be any more convenient than just storing the image name in the table and using files.

Seriously, this method is really not very good and you need to not use it.

Re: image manipulation php mysql blob type

Posted: Tue May 31, 2011 1:29 pm
by Dominion
You may want to explain that loading time for stored images is ridiculously high, and the it's been designed to store data not images rather then just saying it's bad?
Your best bet it to store the files. If you need the path to the files in the database so be it.

Re: image manipulation php mysql blob type

Posted: Tue May 31, 2011 4:37 pm
by jacek
Dominion wrote:You may want to explain that loading time for stored images is ridiculously high, and the it's been designed to store data not images rather then just saying it's bad?

Actually I'm not saying that because the loading times would not be that high, and an image is just data.

the reason I am saying it's not a good idea is that it will add extra load to the mysql server than just using files would, meaning you will need to upgrade the servers pretty quickly. Also it means that the database size will grow very quickly whcih may eventually become a problem.

Re: image manipulation php mysql blob type

Posted: Tue May 31, 2011 5:06 pm
by Dominion
The extra load is why loading time become ridiculously high. Yes a picture is just data, but not data this type of database is optimized for.