Jump to content

phpThumb & MySQL, displaying multiple BLOBs from a single row


Recon

Recommended Posts

I'm using phpThumb to make thumbnails of images stored as BLOBs on a database. I have 3 BLOBs per row (img1, img2 & img3) but I can't work out how to display each image using phpThumb.

I'm a newbie to PHP and MySQL so I don't really know what I'm doing.

config file
[code]$PHPTHUMB_CONFIG['mysql_query'] = 'SELECT img1,img2,img3 FROM `products` WHERE (`id` = \''.mysql_escape_string(@$_GET['id']).'\')';

$PHPTHUMB_CONFIG['mysql_query'] is blank.
$PHPTHUMB_CONFIG['mysql_hostname'] = 'localhost';
$PHPTHUMB_CONFIG['mysql_username'] = '*******';
$PHPTHUMB_CONFIG['mysql_password'] = '********';
$PHPTHUMB_CONFIG['mysql_database'] = '*******';[/code]

phpThumb.php
[code]if ($phpThumb->config_mysql_query) {
if ($cid = @mysql_connect($phpThumb->config_mysql_hostname, $phpThumb->config_mysql_username, $phpThumb->config_mysql_password)) {
if (@mysql_select_db($phpThumb->config_mysql_database, $cid)) {
if ($result = @mysql_query($phpThumb->config_mysql_query, $cid)) {
if ($row = @mysql_fetch_array($result)) {

mysql_free_result($result);
mysql_close($cid);
$phpThumb->setSourceData($row[0]);
unset($row);

} else {
mysql_free_result($result);
mysql_close($cid);
$phpThumb->ErrorImage('no matching data in database.');
}
} else {
mysql_close($cid);
$phpThumb->ErrorImage('Error in MySQL query: "'.mysql_error($cid).'"');
}
} else {
mysql_close($cid);
$phpThumb->ErrorImage('cannot select MySQL database: "'.mysql_error($cid).'"');
}
} else {
$phpThumb->ErrorImage('cannot connect to MySQL server');
}
unset($_GET['id']);
}[/code]

How should I set this up to work?

web page
[code]<img src='phpThumb.php?id=$id&w=100px&h=40px&zc=1' alt='Image'>
<img src='phpThumb.php?id=$id&w=100px&h=40px&zc=1' alt='Image'>
<img src='phpThumb.php?id=$id&w=100px&h=40px&zc=1' alt='Image'>[/code]
Link to comment
Share on other sites

I tried to do this to select img1, img2 and img3:

[code]<img src='phpThumb.php?id=$id&type=img1' alt='Image'>
<img src='phpThumb.php?id=$id&type=img2' alt='Image'>
<img src='phpThumb.php?id=$id&type=img3' alt='Image'>[/code]

With:
[code]$PHPTHUMB_CONFIG['mysql_query'] = 'SELECT \''.mysql_escape_string(@$_GET['type']).'\' FROM `products` WHERE (`id` = \''.mysql_escape_string(@$_GET['id']).'\')';[/code]

But it doesn't work.  :(
Link to comment
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.