Jump to content

camdes

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Everything posted by camdes

  1. Worked at it another way but still having problems. The following code is not the one I will be finally using but I am trying to do one step at a time. The table I am showing should have a thumbnail in one column and a link path in another. This is just to show that the SELECT statement is working. The first column does not show the thumbnails and does not even pick up the path while the second column does and the links work. Can anyone help, I seem to have been at this for ever. <?php $SQL = 'SELECT photo_id, photo_thumbnail FROM gallery_photos '; // execute SQL statement $ret = mysql_db_query($dbname,$SQL,$link); $numrows = mysql_num_rows($ret); if (!$ret) { echo( mysql_error()); } else { while ($img = mysql_fetch_array($ret)) { $id = $img[photo_id]; $thumbnail = $img[photo_thumbnail]; $i = $numrows; echo ("<TR>"); echo ('<td> <img src=<?php echo ("$thumbnail");?>> </td>'); echo ("<TD><a href=\"$thumbnail\" target=_blank>$thumbnail</a></TD>\n"); echo ("</TR>"); } echo ("</TABLE>"); } ?>
  2. After much research and hair pulling I have managed to get my photos uploaded, resized and have created thumbnails which are stored in a separate directory. All the required information about the uploaded files including the paths are stored in a Mysql database. My problem now is that when I retrieve all the thumbnails in a category I can only display them in a single column. I would like to display them in 4 or 6 columns with as many rows as required, can someone help a newbie please.
  3. I am trying to create a photo gallery and there are various reasons why I need to create it from scratch. Unfortunately I am very much a beginner and have been using various books and tutorials to try to get this done. Below is the code for my upload file and I have been building it gradually. I have now added the resize function. I had placed this function in a separate PHP file which I called with e require. The function was not found so I embedded it in the file but I get the following errors: Warning: imagesx(): supplied argument is not a valid Image resource in C:\wamp\www\phototest\reqfiles\submit_photos_resize.req.php on line 68 Warning: imagesy(): supplied argument is not a valid Image resource in C:\wamp\www\phototest\reqfiles\submit_photos_resize.req.php on line 69 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in C:\wamp\www\phototest\reqfiles\submit_photos_resize.req.php on line 83 Warning: imagedestroy(): supplied argument is not a valid Image resource in C:\wamp\www\phototest\reqfiles\submit_photos_resize.req.php on line 90 Warning: imagesx(): supplied argument is not a valid Image resource in C:\wamp\www\phototest\reqfiles\submit_photos_resize.req.php on line 68 Warning: imagesy(): supplied argument is not a valid Image resource in C:\wamp\www\phototest\reqfiles\submit_photos_resize.req.php on line 69 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in C:\wamp\www\phototest\reqfiles\submit_photos_resize.req.php on line 83 Warning: imagedestroy(): supplied argument is not a valid Image resource in C:\wamp\www\phototest\reqfiles\submit_photos_resize.req.php on line 90 Your Photograph was successfully uploaded! Warning: Unexpected character in input: ''' (ASCII=39) state=1 in C:\wamp\www\phototest\reqfiles\image_functions.req.php on line 26 Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\phototest\reqfiles\image_functions.req.php on line 26 Here is my code: <?php $uploadid = $_SESSION['loginID']; $uploaddate = date("j-n-y, G:i:s"); $userfile_name=$HTTP_POST_FILES['userfile']['name']; $userfile_size=$HTTP_POST_FILES['userfile']['size']; $userfile_type=$HTTP_POST_FILES['userfile']['type']; $ph_category=$HTTP_POST_VARS['category']; $ph_caption=$HTTP_POST_VARS['caption']; if ($ph_category == "Select Category") { echo ("You have not selected a category for this photograph<BR>\n"); exit; } //check to see if a file is uploaded at all if ($userfile_size >= 2000000) { echo ("This file is too large<BR>\n"); echo ("Please reduce the resolution or size of photograph<BR>\n"); echo ("The file size must be below 2 megabytes and try again<BR>\n"); exit; } //echo ("upload id: $uploadid<BR>\n"); echo ("upload date: $uploaddate<BR>\n"); echo ("category: $ph_category<BR>\n"); echo ("new file name: $userfile_name<BR>\n"); echo ("caption: $ph_caption<BR>\n"); $photoname="../gallery/$userfile_name"; //check for empty file echo ("filesize: $userfile_size<BR>\n"); if ($userfile_size==0) { echo "Error: File uploaded has no image"; exit; } //set upload directory (below) to whatever you need on the server $photoupfile = "../gallery/$userfile_name"; if ( !copy($userfile, $photoupfile)) { echo "Error: Could not save file. <br>.mysql_error())"; exit; } //report file upload successful! echo "$photoname uploaded successfully!<br>"; // Resize photographs function createsmall($name, $filename, $new_w, $new_h){ $system=explode('.',$name); if (preg_match('/jpg|jpeg/',$system[1])){ $src_img=imagecreatefromjpeg($name); } if (preg_match('/png/',$system[1])){ $src_img=imagecreatefrompng($name); } $old_x=imageSX(src_img); $old_y=imageSY($src_img); if ($old_x > $old_y) { $small_w=$new_w; $small_h=$old_y*($new_w/$old_x); } if ($old_x < $old_y) { $small_w=$old_x*($new_w/$old_y); $small_h=$new_h; } if ($old_x == $old_y) { $small_w=$new_w; $small_h=$new_h; } $dst_img=ImageCreateTrueColor($small_w,$small_h); imagecopyresampled($dst_img,$src_img,0,0,0,0,$small_w,$small_h,$old_x,$old_y); if (preg_match('/png/',$system[1])) { imagepng($dst_img,$filename); } else { imagejpeg($dst_img,$filename); } imagedestroy($dst_img); imagedestroy($src_img); createsmall('$photoname','../gallery/images/i_$userfile_name',640,640); createsmall('$photoname','../gallery/thumbs/t_$userfile_name',70,70); $new_image=('../gallery/images/i_$userfile_name'); $new_thumb=('../gallery/thumbs/t_$userfile_name'); $query = "INSERT INTO gallery_photos (photo_filename, photo_thumbnail, photo_caption, photo_category, upload_id, upload_date )". "VALUES ('$new_image','$new_thumb','$ph_caption', '$ph_category','$uploadid','$uploaddate')"; //echo ("The query is: <BR>$query<P>\n"); if (mysql_db_query ($dbname, $query, $link)){ echo ("Your Photograph was successfully uploaded!<BR>\n"); } else { echo(mysql_error()); echo ("Your photograph could not be uploaded.<BR>\n"); } mysql_close ($link); ?>
×
×
  • 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.