Jump to content

[SOLVED] create thumb image, update mysql


quasiman

Recommended Posts

Hello all,

 

I'm using Joomla's Virtuemart component, and I need to thumbnail all of the product images.  I have a script that does this part perfectly, but of course I have to also update the database to know which images to use.  I'm not getting any errors, in fact my results say successful....but then I look in phpMyAdmin and nothing has changed.  Below is my script, please take a look and let me know what I'm missing.

Thanks!

<?php
ini_set('display_errors', 1);
ini_set('log_errors', 1);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
error_reporting(E_ALL);
include ('/outsidewebroot/dbconnect.php');
$linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host.");
mysql_select_db($dbase, $linkID) or die('Error: ' . mysql_error());
//Open images directory
$dir = opendir("components/com_virtuemart/shop_image/product");
//List files in images directory
while (false !== ($file = readdir($dir)))
  {
if ($file != "." && $file != ".." && $file != "index.html" && $file != "resized") {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "thumb.php?src=".$file."&dest=tn_".$file."&x=90&y=90");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
$resizedfile = "resized/tn_".$file;
$update = 'UPDATE jos_vm_product SET product_thumb_image = "$resizedfile" WHERE product_full_image ="$file"';
if (!mysql_query($update,$linkID))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";
echo $resizedfile."<br>";
}
}
closedir($dir);
mysql_close($linkID)
?> 

Link to comment
https://forums.phpfreaks.com/topic/169150-solved-create-thumb-image-update-mysql/
Share on other sites

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.