Jump to content

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

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.