This thread is based on http://aimmultimedia.com/viewpage.php?page_id=3 , where there are couple of problems. (Try uploading for yourself).
First problem: My first query runs perfectly, but my 2nd mysql query doesn't. Whats wrong?
First Query
$viewid = $_GET["id"];
$result = mysql_query("SELECT * FROM registered_files WHERE viewid = '$viewid'");
$myrow = mysql_fetch_array($result);
Second Query
<?php $result2 = mysql_query("UPDATE registered_files SET hits=hits+1 WHERE id = '$viewid'") or die (mysql_error());
$rowyourboat = mysql_fetch_array($result2);
echo $rowyourboat["hits"] ?>
Error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/lpxxfain/public_html/membersimage.php on line 36
Second Question: On the same upload page, I recently installed a watermarking system, and it works fine. The problem is when it watermarks small images, it totally messes it up. Is there any way so that it doesn't water mark images that are too small?
Example Normal : http://aimmultimedia.com/membersimage.php?id=Gdubs!4
Example Small : http://aimmultimedia.com/membersimage.php?id=Affiliate8
Source:
function_watermark.php
<?php
function watermark($SourceFile, $WatermarkFile, $SaveToFile = NULL)
{
$watermark = @imagecreatefrompng($WatermarkFile)
or exit('Cannot open the watermark file.');
imageAlphaBlending($watermark, false);
imageSaveAlpha($watermark, true);
$image_string = @file_get_contents($SourceFile)
or exit('Cannot open image file.');
$image = @imagecreatefromstring($image_string)
or exit('Not a valid image format.');
$imageWidth=imageSX($image);
$imageHeight=imageSY($image);
$watermarkWidth=imageSX($watermark);
$watermarkHeight=imageSY($watermark);
$coordinate_X = ( $imageWidth - 5) - ( $watermarkWidth);
$coordinate_Y = ( $imageHeight - 5) - ( $watermarkHeight);
imagecopy($image, $watermark, $coordinate_X, $coordinate_Y,
0, 0, $watermarkWidth, $watermarkHeight);
if(!($SaveToFile)) header('Content-Type: image/jpeg');
imagejpeg ($image, $SaveToFile, 100);
imagedestroy($image);
imagedestroy($watermark);
if(!($SaveToFile)) exit;
}
?>
membersupload.php
<?php
ob_start();
UPLOAD CODE WAS HERE
header("Location: http://aimmultimedia.com/process2.php?id=$id&ext=$ext&viewid=$viewid");
};
ob_end_flush();
?>
Process2.php
<?php
ob_start();
// The image should be located in a non public directory
$id = $_GET['id'];
$ext = $_GET['ext'];
$viewid = $_GET['viewid'];
$image_location = '/home/lpxxfain/public_html/members/images/'.$id. '.' .$ext ;
// Locate the watermark file wherever you choose (remember PNG format)
$watermark_location = '/home/lpxxfain/public_html/members/water.png';
// Location where you want to save the created watermarked file
$save_watermarked_file_to = '/home/lpxxfain/public_html/members/images/imagesbin/'.$id. '.' .$ext;
// Include the watermarking function file
require_once($_SERVER['DOCUMENT_ROOT'] . '/function_watermark.php');
// Watermark the image and save it to file
watermark($image_location, $watermark_location, $save_watermarked_file_to);
header("Location: http://aimmultimedia.com/membersimage.php?id=$viewid");
ob_end_flush();
?>
3rd Question: Is there any way so that if there is no $GET['editid'] then the script runs normally, and when there is a $GET it run's something different?
Help would be greatly appreciated.
-AIMMultimedia.com