Jump to content

theredking

Members
  • Posts

    48
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

theredking's Achievements

Member

Member (2/5)

0

Reputation

  1. Ok, this is almost exactly what I want it to do now, but it only re-inserts this header information once. Is there a way to tell it to insert it every 10 or twelve rows? I have tried: if ($i == 10) { but obviously this only inserts it after the 10th row, it doesn't do it every 10 rows. I'm going to keep trying to figure this out, but any help would be greatly appreciated. Thanks
  2. Hi Premiso, I just tried your suggestion, and that seems to insert the header information after every results row that is printed... Is that what it should do? Thanks
  3. I've cut out most of the code to just show you the loop. I'm not quite sure how to get the if statement worked into here and then reset the loop. Thanks again. $num = mysql_numrows($result); $i = 0; while ($i < $num) { print "data goes here."; $i++; }
  4. Wow, sorry all, I didn't get any notification that there had been replies to this topic. Thank you so much, I'll take a look at this and get right back to you all. Thank you again!
  5. Hello all, just a quick question: I have a while loop populating a table for which I've already written a header. This table ends up having quite a number of rows, and the information in the header is lost as you scroll down the table. Is there a way to interrupt the while loop, re-insert the header information and then continue the loop until it finishes? Thanks all in anticipation..
  6. I've been struggling with this for a couple of days now, and have done everything I can to try and solve the problem on my own, but I don't think I can. I have created a form to upload an image and sometimes it works, and sometimes it doesn't, and that's the problem! I want to be able to upload an image of max size 6M. I have tried this using PHP 5.2.6, and 4.4.8, and for both I have upload_max_filesize set to 6M, post_max_size set to 8M. With 4.4.8 it seems I can upload files up to 3MB, but if I try a 5.3MB file it fails, although I'm not totally convinced this is consistent yet, or why it fails. The problem is, I am also creating a thumbnail of this image and when using 4.4.8, I pretty consistently get an error saying "Allowed memory size of 33554432 bytes exhausted..." which is why I've been experimenting with 5.2.6. But, 5.2.6 rarely lets me upload an image larger than 1MB even though the settings (as stated above) are the same. So I am guessing that my problems with 4.4.8 are that there is not enough memory to perform the image resize using imagecreatefromjpeg function (as it successfully uploads the initial image but errors at the imagecreatefromjpeg script stage), and the problem with 5.2.6 is something to do with move_uploaded_file (as the error message occurs before the thumbnail script is attempted). I'm a novice when it comes to PHP, having just read Larry Ulman's PHP for the World Wide Web, but I'm trying my best! Any suggestions you may have will be greatly appreciated. Here is the code, currently I have the thumbnail code commented out as I was trying to trouble shoot the issues with move_uploaded_file in 5.2.6 function processForm() { $allowed_filetypes = array('.jpg','.JPG','.gif','.bmp','.png'); $max_filesize = 6291456; $upload_path = '/home/myserver/www/uploads/'; $upload_thumb_path = $upload_path.'thumbs/'; $filename = $_FILES['userfile']['name']; $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); $filename = "{$_POST['last_name']}"."_"."{$_POST['first_name']}"."_".time() . "$ext"; if(!in_array($ext,$allowed_filetypes)) die('The file you attempted to upload is not allowed.'); if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize) die('The file you attempted to upload is too large.'); if(!is_writable($upload_path)) die('You cannot upload to the specified directory, please CHMOD it to 777.'); if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename)) { print '<p>Your file has been successully uploaded, <a href="/uploads/' . $filename . '">click here</a> to view your file.</p>'; // It worked. /* if(copy($upload_path.$filename, $upload_thumb_path.$filename)) { print '<p>Thumbnail file created successfully. '; list($width, $height) = getimagesize($upload_path.$filename); $width_thumb = 160; $height_thumb = 200; $thumb = imagecreatetruecolor($width_thumb, $height_thumb); $source = imagecreatefromjpeg($upload_thumb_path.$filename); if(imagecopyresampled($thumb, $source, 0, 0, 0, 0, $width_thumb, $height_thumb, $width, $height)) { imagejpeg($thumb, $upload_thumb_path.$filename, 100); print 'Thumbnail successfully resized, <a href="/uploads/thumbs/' . $filename . '">click here</a> to view your file.</p>'; } else { print '<p>Thumbnail resize process hit a wall!</p>'; } } else { print '<p>Thumbnail hit a wall!</p>'; } */ } else print '<p>There was an error during the file upload. Please try again.</p>'; // End processForm function }
  7. Hi, I've been trying to do something very similar to this myself, and ended up just using this script because it was almost exactly what I needed. I am running into a couple of strange problems though, and I'm not exactly sure what is causing them. I am only attempting to upload jpeg images, and some images upload fine, but others result in the "There was an error during the file upload. Please try again." error. I cannot work out what it is about these images that make this happen. I'm pretty sure that if they are CMYK then that results in the error, but I have uploaded RGB images that have given the same error. I'm a little stuck. Here is my code, just slightly altered $allowed_filetypes = array('.jpg','.JPG','.gif','.bmp','.png'); $max_filesize = 33554432; $upload_path = '/home/myserver/www/uploads/'; $upload_thumb_path = $upload_path.'thumbs/'; $filename = $_FILES['userfile']['name']; $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); $filename = "{$_POST['last_name']}"."_"."{$_POST['first_name']}"."_".time() . "$ext"; if(!in_array($ext,$allowed_filetypes)) die('The file you attempted to upload is not allowed.'); if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize) die('The file you attempted to upload is too large.'); if(!is_writable($upload_path)) die('You cannot upload to the specified directory, please CHMOD it to 777.'); if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename)) { print '<p>Your file has been successully uploaded, <a href="/uploads/' . $filename . '">click here</a> to view your file.</p>'; // It worked. if(copy($upload_path.$filename, $upload_thumb_path.$filename)) { print '<p>Thumbnail file created successfully. '; list($width, $height) = getimagesize($upload_path.$filename); $width_thumb = 160; $height_thumb = 200; $thumb = imagecreatetruecolor($width_thumb, $height_thumb); $source = imagecreatefromjpeg($upload_thumb_path.$filename); if(imagecopyresampled($thumb, $source, 0, 0, 0, 0, $width_thumb, $height_thumb, $width, $height)) { imagejpeg($thumb, $upload_thumb_path.$filename, 100); print 'Thumbnail successfully resized, <a href="/uploads/thumbs/' . $filename . '">click here</a> to view your file.</p>'; } else { print '<p>Thumbnail resize process hit a wall!</p>'; } } else { print '<p>Thumbnail hit a wall!</p>'; } } else print '<p>There was an error during the file upload. Please try again.</p>'; Any suggestions would be greatly appreciated.
  8. Thank you all, I got myself confused trying to use the "&&" operator, clearly! :-\
  9. Hello... I'm trying to create an if statement that creates two outcomes. The else, and elseifs will also work in the same format. If I do it this way, link2 works, but link 1 becomes "www.mysite.com/scripts/1" if ($choice=="Banana") $link1 = "http://www.mysite.com/1" && $link2 = "http://www.mysite.com/2"; What am I doing wrong? Thank you in anticipation! Rory
  10. Yeh I do realise... But being so new to this, it's a little like trying to put a shoe on and tie it whilst upside down in a dark room, being spun around, and people are poking you with sticks... I'm trying, it's just hard to get my head around combining these things. Thanks
×
×
  • 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.