Nathan Brignall Posted August 15, 2008 Share Posted August 15, 2008 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 More sharing options...
Fadion Posted August 15, 2008 Share Posted August 15, 2008 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. Link to comment https://forums.phpfreaks.com/topic/119890-bringing-a-mediumblob-into-php/#findComment-617721 Share on other sites More sharing options...
Nathan Brignall Posted August 16, 2008 Author Share Posted August 16, 2008 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); ?> Link to comment https://forums.phpfreaks.com/topic/119890-bringing-a-mediumblob-into-php/#findComment-618022 Share on other sites More sharing options...
Fadion Posted August 16, 2008 Share Posted August 16, 2008 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']; } ?> Link to comment https://forums.phpfreaks.com/topic/119890-bringing-a-mediumblob-into-php/#findComment-618170 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.