mikey3521 Posted October 5, 2007 Share Posted October 5, 2007 Hello, I've managed to code an upload script which I can upload images to the database, with a Title, and a PID (picture id) which gets auto assigned. Now I want to return a list with thumbnails of those pictures... I can get the picture to just display on a page by itself, but I can't seem to generate a thumbnail.. Heres the code I have and you'll see where im stuck <?php if (! @mysql_connect("localhost","majestic_majesti","pellegrino")) { $errmsg = "Cannot connect to database"; } @mysql_select_db("majestic_majesticminds"); $query="SELECT * FROM pix "; $result=mysql_query($query); $num = mysql_num_rows ($result); mysql_close(); if ($num > 0 ) { $i=0; while ($i < $num) { $title = mysql_result($result,$i,"title"); $pid = mysql_result($result,$i,"pid"); $imgdata = mysql_result($result,$i,"imgdata"); echo "<b>Image ID:</b> $pid<br>"; echo "<b>Image Title:</b> $title<br>"; echo "<img src=$imgdata width=400>"; echo "<br><br>"; ++$i; } } else { echo "The database is empty"; } ?> Only problem is when I do an img src=$imgdata I don't see the picture, I see the blob data like this: ³0 blÓ šòyu|Q*é‹ÇX™(Íí¤ÂÈêªÈ)’ù„ÿy«’«ëÌG1Õ~=¸ñrosÖä®±B ÞR‡ø;}%€D¤¬¬˜rd¹^„¥2ûõDC"‹\šuÚJÓt`^P‰Ü%ôïK0Õh턲Rݨ¢ £ønÄT¥y’`¡ÎMÇõž3°(%;pNèídžc1RæO¡â<+ã·B^F£êSÓýˆ]o¦®Z*²\•»]8NÞŽÇhõš@gýí{±9P[·|ó€×¿¹fw\«‹kíüÖìspgÜïÀñjü‹}½5òêù-Ì•“D…Hña‹n¶¤óÃÅÕpŒucìmr ·1±½—i]½1' å‹ôÞò4:Gé`Brh*ä40ï§>K¥¤ŒiËE}ÇH37WÔ„„»¥¡ùI£ûS"ŒÉhT"9IØ(éõÄ›^{´Y6J\ÂR* ÄËÒ3lðƒóŸj/_é÷¶VTjïë;bûiØÀ Thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/71988-mysql-blob-img/ Share on other sites More sharing options...
BlueSkyIS Posted October 5, 2007 Share Posted October 5, 2007 Thoughts? don't store images in a database. Quote Link to comment https://forums.phpfreaks.com/topic/71988-mysql-blob-img/#findComment-362648 Share on other sites More sharing options...
mikey3521 Posted October 5, 2007 Author Share Posted October 5, 2007 recommendations?? Trying to store a bunch of images that will be loaded on the site and searchable by category, name, etc Quote Link to comment https://forums.phpfreaks.com/topic/71988-mysql-blob-img/#findComment-362652 Share on other sites More sharing options...
BlueSkyIS Posted October 5, 2007 Share Posted October 5, 2007 store the images in a directory and store the name and/or path to each image as a text field in your database. simply link to the real images using the file name and/or path stored in the database. i prefer to create thumbnails at the same time i upload images. for that you'd want to look into the GD stuff. Quote Link to comment https://forums.phpfreaks.com/topic/71988-mysql-blob-img/#findComment-362658 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.