Jump to content

rajeevthomas

Members
  • Posts

    26
  • Joined

  • Last visited

Everything posted by rajeevthomas

  1. Thank you Jaques1 with your help my code is now HTML-escaped...thanks again!.
  2. Jaques, thank you!. Sorry about my late reply. And thank you for your code. Now I have somewhere to start from. The array idea is cool. is 'html_escape' a PHP function? I couldn't find out much about it.
  3. Thank you guys. Looking at your answers I realize that I did not ask my question right. I am sorry about that. My case is a bit different I think. I think it is because I am trying to create the link from inside PHP. My code is $result_final .= "<a href=viewgallery.php?cname=$cname&pcaption=" . $caption_array[$next] . "><img src='/photos/assets/left.png' alt='left navigation'></a>"; So based on your answers ... I changed the links like this $result_final .= "<a href=\"viewgallery.php?cname=$cname&pcaption=" . $caption_array[$next] . "\"><img src='/photos/assets/left.png' alt='left navigation'></a>"; It really works. Thank you for the suggestions. No more errors.... ( for now ) Just out of curiosity, is this a bad way of creating links? Is this a hideous code? Thank you for helping me,....
  4. Hi Everyone.. I am not sure if I should post this question here. I would like to fix this problem using PHP rather than HTML. I am new to PHP. This code is part of an old PHP gallery file. I am trying to validate my site but the site's links have some characters that makes the link throw errors in W3C Validator. So I tried to replace the characters with HTML characters for example ? are now replaced by ? so my original link before using valid HTML characters looked like www.awebsite.com/viewgallery.php?cname=Colorado-Fall&pcaption=Lost-In-The-art And now it looks like this ... www.awebsite.com/viewgallery.php?cname=Colorado-Fall&pcaption=Lost-In-The-art But now W3C Validator shows an error like this The ? for replacing ? seems to be the problem.The & is highlighted in red. What am I doing wrong? How can I validate this link? I tried to use single or double quotes around HTML characters but that breaks my links and they won't work after that. Any tips will be appreciated...
  5. Thank you Mac_gyver, I will be the only one uploading. But I will learn how to report back the errors... thanks again...
  6. Hi everyone... I am a beginner. For a gallery I have, I am trying to upload thumbnails and sharpen them using image convolution. I am not sure I am doing the right thing or not. I am not getting arrors but I do not see any sharpening effect!! So I know I am dead wrong some where...! Please help me with this.... I am also not st sure I have the right source for $img... This is where I need some help... [color=red] $img = ImageCreateTrueColor ( $thumbnail_width, $thumbnail_height); $sharpenMatrix = array ( array(-1.2, -1, -1.2), array(-1, 20, -1), array(-1.2, -1, -1.2) ); // calculate the sharpen divisor $divisor = array_sum(array_map('array_sum', $sharpenMatrix)); $offset = 0; // apply the matrix imageconvolution($img, $sharpenMatrix, $divisor, $offset); [/color] This is my code for the upload file.... include("config.inc.php"); if(!$_POST) { header("Location: preupload.php"); exit(); } // initialization $result_final = ""; $counter = 0; // List of our known photo types $known_photo_types = array( 'image/pjpeg' => 'jpg', 'image/jpeg' => 'jpg', 'image/gif' => 'gif', 'image/bmp' => 'bmp', 'image/x-png' => 'png' ); // GD Function List $gd_function_suffix = array( 'image/pjpeg' => 'JPEG', 'image/jpeg' => 'JPEG', 'image/gif' => 'GIF', 'image/bmp' => 'WBMP', 'image/x-png' => 'PNG' ); // Fetch the photo array sent by preupload.php $photos_uploaded = $_FILES['photo_filename']; // Fetch the photo caption array $photo_caption = $_POST['photo_caption']; // Fetch the photo caption array $photo_description = $_POST['photo_description']; // Fetch the photo caption array $photo_keyword = $_POST['photo_keyword']; while( $counter <count($_FILES['photo_filename']['tmp_name']) ) { if($photos_uploaded['size'][$counter] > 0) { if(!array_key_exists($photos_uploaded['type'][$counter], $known_photo_types)) { $result_final .= "File ".($counter+1)." is not a photo<br />"; } else { mysql_query( "INSERT INTO gallery_photos ( `photo_filename`, `photo_caption`, `photo_description`, `photo_keywords`, `photo_category` ) VALUES( '0', '".addslashes($photo_caption[$counter])."', '".addslashes($photo_description[$counter])."', '".addslashes($photo_keyword[$counter])."', '".addslashes($_POST['category'])."')" ) or die(mysql_error() . 'Photo not uploaded'); $new_id = mysql_insert_id(); $filetype = $photos_uploaded['type'][$counter]; $extention = $known_photo_types[$filetype]; $filename = $new_id.".".$extention; mysql_query( "UPDATE gallery_photos SET photo_filename='".addslashes($filename)."' WHERE photo_id='".addslashes($new_id)."'" ); // Store the orignal file copy($photos_uploaded['tmp_name'][$counter], $images_dir."/".$filename); // Let's get the Thumbnail size $size = GetImageSize( $images_dir."/".$filename ); if($size[0] > $size[1]) { $thumbnail_width = 500; $thumbnail_height = (int)(500 * $size[1] / $size[0]); } else { $thumbnail_width = (int)(500 * $size[0] / $size[1]); $thumbnail_height = 500; } // Build Thumbnail with GD 1.x.x, you can use the other described methods too $function_suffix = $gd_function_suffix[$filetype]; $function_to_read = "ImageCreateFrom".$function_suffix; $function_to_write = "Image".$function_suffix; // Read the source file $source_handle = $function_to_read ( $images_dir."/".$filename ); if($source_handle) { // Let's create an blank image for the thumbnail $destination_handle = ImageCreateTrueColor ( $thumbnail_width, $thumbnail_height ); // Now we resize it imagecopyresampled( $destination_handle, $source_handle, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $size[0], $size[1] ) ; } [color=red] $img = ImageCreateTrueColor ( $thumbnail_width, $thumbnail_height); $sharpenMatrix = array ( array(-1.2, -1, -1.2), array(-1, 20, -1), array(-1.2, -1, -1.2) ); // calculate the sharpen divisor $divisor = array_sum(array_map('array_sum', $sharpenMatrix)); $offset = 0; // apply the matrix imageconvolution($img, $sharpenMatrix, $divisor, $offset); [/color] // Let's save the thumbnail $function_to_write( $destination_handle, $images_dir."/tb_".$filename, 100 ); ImageDestroy($destination_handle ); // $result_final .= "<img src='".$images_dir. "/tb_".$filename."' /> File ".($counter+1)." Added<br />"; } } $counter++; } // Print Result echo <<<__HTML_END <html> <head> <title>Photos uploaded</title> </head> <body> $result_final </body> </html> __HTML_END;
×
×
  • 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.