Jump to content


Photo

Blob field


  • Please log in to reply
5 replies to this topic

#1 otello45

otello45

    Newbie

  • Member
  • Pip
  • 2 posts

Posted 08 February 2006 - 11:42 AM

I am a newbie with php and I do not understand why the following code doesn't display any image I previously stored in mysql blob fields. The image type i get is correct, and if I get rid of header function the only thing displayed is the raw image data. All image files stored are not greater than 300K in size, the upload_max_filesize php directive is set to 2M and MySql max_allowed_packet = to 1M

I am using Uniform Server 3.2a. Can anyone help me?

<?php
include ("connet_info_mysql.php");
$idfoto = (isset($_GET["idfoto"])) ? $_GET["idfoto"] : exit();
$tam = (isset($_GET["tam"])) ? $_GET["tam"] : 1;

switch($tam) {
case "1":
$campo = "foto";break;
case "2":
$campo = "thumb";break;
default:
$campo = "foto";break;
}

$sql = "SELECT $campo, mime FROM tabellaFoto WHERE idfoto = $idfoto";
$link = mysql_connect(DBHOST, DBUSER, DBPASSWORD) or die(mysql_error($link)); // Connessione al database.
mysql_select_db(DBNAME, $link) or die(mysql_error($link));
$conn = mysql_query($sql, $link) or die(mysql_error($link));
$dati = mysql_fetch_array($conn);
$immagine = $dati[0];
$mime = $dati[1];
Header("Content-type: $mime");
echo $immagine;
//echo $mime;
?>

Could you also tell me how to change the MySql variable max_allowed_packet value when using Uniform Server?

#2 olajideolaolorun

olajideolaolorun

    Project Manager

  • Admin
  • PipPipPipPipPip
  • 2,347 posts
  • Gender:Male
  • Location:Atlanta, GA
  • SourceForge IDempirex
  • Wiki ID: olajideolaolorun
  • IRC Nickname: Olajide
  • Main OS: Windows 10

Posted 13 February 2006 - 09:20 AM

I will have to get back to you... i also had to did what you are about to do and it took me a while cause no one knew anything about it.... so i had to write from scratch and so on....

Its a simple function to retrieve the image but i can't remember it... have to check at home and get back to you tomorrow... just remind me.

#3 otello45

otello45

    Newbie

  • Member
  • Pip
  • 2 posts

Posted 13 February 2006 - 04:15 PM

I am a newbie with php and I do not understand why the following code doesn't display any image I previously stored in mysql blob fields. The image type i get is correct, and if I get rid of header function the only thing displayed is the raw image data. All image files stored are not greater than 300K in size, the upload_max_filesize php directive is set to 2M and MySql max_allowed_packet = to 1M

I am using Uniform Server 3.2a. Can anyone help me?

<?php
include ("connet_info_mysql.php");                                             
$idfoto = (isset($_GET["idfoto"])) ? $_GET["idfoto"] : exit();
$tam = (isset($_GET["tam"])) ? $_GET["tam"] : 1;

switch($tam) {
case "1":
  $campo = "foto";break;
case "2":
  $campo = "thumb";break;
default:
$campo = "foto";break;
}

$sql = "SELECT $campo, mime FROM tabellaFoto WHERE idfoto = $idfoto";         
$link = mysql_connect(DBHOST, DBUSER, DBPASSWORD) or die(mysql_error($link));  // Connessione al database.
mysql_select_db(DBNAME, $link) or die(mysql_error($link));                     
$conn = mysql_query($sql, $link) or die(mysql_error($link));                   
$dati = mysql_fetch_array($conn);
$immagine = $dati[0];                                                         
$mime = $dati[1];                                                             
Header("Content-type: $mime");
echo $immagine;                                                               
//echo $mime;
?>

Could you also tell me how to change the MySql variable max_allowed_packet value when using Uniform Server?

View Post


Don't worry Oleji, I figure out the problem. I Simply take the include function off and wrote manually all the connection data such as DBHOST,DBUSER,... just stupidly defined in the include function itself. I also got how to change the max_allowed_packet variable hidden in the my.cnf file. Windows didn't show the extension of the file and that confused me a bit.
Thanks anyway Oleji, I read you and find you great. Sorry for my English

#4 olajideolaolorun

olajideolaolorun

    Project Manager

  • Admin
  • PipPipPipPipPip
  • 2,347 posts
  • Gender:Male
  • Location:Atlanta, GA
  • SourceForge IDempirex
  • Wiki ID: olajideolaolorun
  • IRC Nickname: Olajide
  • Main OS: Windows 10

Posted 17 February 2006 - 08:45 AM

:) No problem.....

#5 madhouse

madhouse

    Junior Member

  • Member
  • Pip
  • 11 posts

Posted 19 February 2006 - 04:05 PM

you should also put limit 0,1 on you sql query to make sure it only brings out 1

#6 olajideolaolorun

olajideolaolorun

    Project Manager

  • Admin
  • PipPipPipPipPip
  • 2,347 posts
  • Gender:Male
  • Location:Atlanta, GA
  • SourceForge IDempirex
  • Wiki ID: olajideolaolorun
  • IRC Nickname: Olajide
  • Main OS: Windows 10

Posted 02 March 2006 - 10:01 AM

If its a big Query... :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users