Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/71988-mysql-blob-img/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/71988-mysql-blob-img/#findComment-362658
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.