Jump to content

bringing a mediumblob into php


Nathan Brignall

Recommended Posts

Hey,

 

I have a mysql table with several fields in it.  I'm not having any trouble with any of the varchar fields, but how to get the mediumblob field has really got me stumped.  Does anyone know how to SELECT a mediumblob from a mysql table and bring it into php?

Link to comment
https://forums.phpfreaks.com/topic/119890-bringing-a-mediumblob-into-php/
Share on other sites

What kind of problems are u having? What are u inserting into the mediumblob field? U should specify those. Anyway, a common use for blobs is to store images, so if thats the case, u should specify a correct header before actually printing that value (image).

 

Place the header before printing the image:

header("Content-type: image/jpeg"); //if the image is jpg

 

The same concept applies to different types of formats.

I'm using it to store images. Thanks for the help. How would I get all my pictures to come onto the page? So far I only get the first image in the database.

 

<?php

 

$link = mysql_connect ("localhost", "mystuff", "mystuff");

mysql_select_db ("mystuff");

 

$result = mysql_query("SELECT mystuff FROM mystuff");

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

echo mysql_result($result, 0);

 

?>

It's easy as you can use mysql_fetch_array() in a while loop to browse all selected rows. This should work i think:

 

<?php
$link = mysql_connect ("localhost", "mystuff", "mystuff");
mysql_select_db ("mystuff");

$result = mysql_query("SELECT mystuff FROM mystuff");
header("Content-type: image/jpeg");
while($values = mysql_fetch_array($result)){
     echo $values['column_name'];
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.