lpxxfaintxx Posted March 27, 2006 Share Posted March 27, 2006 This thread is based on [a href=\"http://aimmultimedia.com/viewpage.php?page_id=3\" target=\"_blank\"]http://aimmultimedia.com/viewpage.php?page_id=3[/a] , 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 QueryPHP Code:[code]$viewid = $_GET["id"];$result = mysql_query("SELECT * FROM registered_files WHERE viewid = '$viewid'");$myrow = mysql_fetch_array($result);[/code]Second QueryPHP Code:[code]<?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"] ?>[/code][!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/lpxxfain/public_html/membersimage.php on line 36[/quote]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 : [a href=\"http://aimmultimedia.com/membersimage.php?id=Gdubs!4\" target=\"_blank\"]http://aimmultimedia.com/membersimage.php?id=Gdubs!4[/a]Example Small : [a href=\"http://aimmultimedia.com/membersimage.php?id=Affiliate8\" target=\"_blank\"]http://aimmultimedia.com/membersimage.php?id=Affiliate8[/a]Source:function_watermark.phpPHP Code:[code]<?phpfunction 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;}?>[/code]membersupload.phpPHP Code:[code]<?phpob_start();UPLOAD CODE WAS HEREheader("Location: http://aimmultimedia.com/process2.php?id=$id&ext=$ext&viewid=$viewid");};ob_end_flush();?>[/code]Process2.phpPHP Code:[code]<?phpob_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 filerequire_once($_SERVER['DOCUMENT_ROOT'] . '/function_watermark.php');// Watermark the image and save it to filewatermark($image_location, $watermark_location, $save_watermarked_file_to);header("Location: http://aimmultimedia.com/membersimage.php?id=$viewid");ob_end_flush();?>[/code]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 Quote Link to comment https://forums.phpfreaks.com/topic/5919-watermarking-mysql-php-problems/ Share on other sites More sharing options...
shocker-z Posted March 27, 2006 Share Posted March 27, 2006 Unable to establish connection to MySQL2002 : Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)i think that you have even bigger problems lol Quote Link to comment https://forums.phpfreaks.com/topic/5919-watermarking-mysql-php-problems/#findComment-21150 Share on other sites More sharing options...
lpxxfaintxx Posted March 27, 2006 Author Share Posted March 27, 2006 No, it's fixed. ;) Quote Link to comment https://forums.phpfreaks.com/topic/5919-watermarking-mysql-php-problems/#findComment-21163 Share on other sites More sharing options...
redarrow Posted March 27, 2006 Share Posted March 27, 2006 [!--quoteo(post=358856:date=Mar 27 2006, 12:24 PM:name=lpxxfaintxx)--][div class=\'quotetop\']QUOTE(lpxxfaintxx @ Mar 27 2006, 12:24 PM) [snapback]358856[/snapback][/div][div class=\'quotemain\'][!--quotec--]No, it's fixed. ;)[/quote]Can you post the fix for other users like me cheers.I was getting right into your site untill i relise that you got a 3rd party script lol.cool!All the best redarrow. Quote Link to comment https://forums.phpfreaks.com/topic/5919-watermarking-mysql-php-problems/#findComment-21164 Share on other sites More sharing options...
shocker-z Posted March 27, 2006 Share Posted March 27, 2006 the whole thing fixed? or just that error i stated?[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?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"] ?>[/quote]You can't echo an array of this because it's an update therefore is doesn't select any data you will need[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?php $result2 = mysql_query("UPDATE registered_files SET hits=(hits+1) WHERE id = '$viewid'") or die (mysql_error());$result3 = mysql_query("SELECT hits FROM registered_files WHERE id = '$viewid'") or die (mysql_error());$rowyourboat = mysql_fetch_array($result3);echo $rowyourboat["hits"] ?>[/quote]That should do the job mate :) Quote Link to comment https://forums.phpfreaks.com/topic/5919-watermarking-mysql-php-problems/#findComment-21169 Share on other sites More sharing options...
lpxxfaintxx Posted March 27, 2006 Author Share Posted March 27, 2006 Well, the error is gone but it just comes out as nothing. Preview: [a href=\"http://aimmultimedia.com/membersimage.php?id=asgdsgdsaga10\" target=\"_blank\"]http://aimmultimedia.com/membersimage.php?id=asgdsgdsaga10[/a]I have the tables set up correctly, I am almost certain. I have the 'hits' field on int(10)Also, does anyone have any ideas about the other questions, like the watermarking one? Thanks a LOT. Quote Link to comment https://forums.phpfreaks.com/topic/5919-watermarking-mysql-php-problems/#findComment-21363 Share on other sites More sharing options...
ToonMariner Posted March 28, 2006 Share Posted March 28, 2006 On the water marking....I think I saw in the script that you grab the dimensions of each image. Simple if statement to check the watermark is smaller than the image - if it is use the watermark - if not do something else (I suggest you just put some text on), or nothing.Your first problem with the query has been sorted out.The final one about whether $_GET['editid'] is set....another if statment...if (isset($_GET['editid'] )) {do something} else {do soemthing else} Quote Link to comment https://forums.phpfreaks.com/topic/5919-watermarking-mysql-php-problems/#findComment-21387 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.