
theredking
Members-
Posts
48 -
Joined
-
Last visited
Everything posted by theredking
-
[SOLVED] interrupt while loop, then resume?
theredking replied to theredking's topic in PHP Coding Help
Perfect. Thank you so much for your time. -
[SOLVED] interrupt while loop, then resume?
theredking replied to theredking's topic in PHP Coding Help
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 -
[SOLVED] interrupt while loop, then resume?
theredking replied to theredking's topic in PHP Coding Help
That's it, thank you! Fantastic!! -
[SOLVED] interrupt while loop, then resume?
theredking replied to theredking's topic in PHP Coding Help
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 -
[SOLVED] interrupt while loop, then resume?
theredking replied to theredking's topic in PHP Coding Help
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++; } -
[SOLVED] interrupt while loop, then resume?
theredking replied to theredking's topic in PHP Coding Help
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! -
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..
-
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 }
-
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.
-
[SOLVED] Stuck with Operators... Easy solution I'm sure
theredking replied to theredking's topic in PHP Coding Help
Thank you all, I got myself confused trying to use the "&&" operator, clearly! :-\ -
[SOLVED] Stuck with Operators... Easy solution I'm sure
theredking replied to theredking's topic in PHP Coding Help
Thank you!! -
[SOLVED] Stuck with Operators... Easy solution I'm sure
theredking posted a topic in PHP Coding Help
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 -
[SOLVED] POST to mysql database and email results?
theredking replied to theredking's topic in PHP Coding Help
Thank you micah1701, that works perfectly!! -
[SOLVED] POST to mysql database and email results?
theredking replied to theredking's topic in PHP Coding Help
Thank you, I'll give this a go! -
[SOLVED] POST to mysql database and email results?
theredking replied to theredking's topic in PHP Coding Help
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 -
Hi, I have a simple html form that POSTs to a mysql database. Can I, and if so, how can I, have it post to the mysql database, and email the form results too. I also have some other html forms that just mail() the results. So I can do both things separately, but I'm not sure how to combine them. I'm still very new to all this... Thank you in anticipation.
-
[SOLVED] Pass the results of an IF statement to a var?
theredking replied to theredking's topic in PHP Coding Help
I answered my own question.... Edit: Thanks for your time lemmin -
Hi all, I'm happily plodding along... but! I would like to pass the results of an if statement to a var if possible. Sort of like how the "foreach" statement works. How do i do this?? Thank you in anticipation.
-
Cool thanks!
-
I'm desperately trying to grasp this simple concept... I can make it work in its simplest forms, but as I try to get more complicated things start to go wrong. If I have a basic if, elseif, else statement: Can I add additional "ifs" inside of this? I want to have multiple ifs to echo my form results based on what is inputted into the form. So, if one thing is inputted, I want to echo certain results, but then instead of an elseif something else, I want to echo something else as well "if" something else is inputted or selected. I'm sure this doesn't make too much sense... I'd post my code, but it's a fair bit of a mess, and would take quite a long time to explain. Is there a great if elseif tutorial anyone could point me to?
-
I'm a little stuck. I am new to this, so it is undoubtedly down to something I clearly do not understand. I'm using mail() and am trying to email the contents of a form. I can do this successfully until I try and make what is emailed from that form a little more complicated. Right now I have: mail( "[email protected]", "This is a test", "Message goes here", "From:$first_name $last_name <$email>\r\nContent-type: text/html; charset=us-ascii"); This works as it should. In my "Message goes here", section I have listed the vars and text, as you might expect, and I am formatting it very basically with simple tags for line break, and strong text etc. The problem I have comes when I am trying to have it send the results of a number of checkboxes. I had a similar problem the other day, and when this problem arose I was offered this code: foreach ($_POST['checkboxname'] as $value) { echo "$value " ; } This worked fine, but I cannot get it to work within my page that has mail() in it. I'm sure this is not right, but I put this entire code inline where I wanted the checkbox array to be displayed. Should I put foreach ($_POST['checkboxname'] as $value) somewhere else, and then just reference the array with $value inside the mail() code with the other variables? I did try this, but it didn't work for some reason. My other thought was to escape out of "Message goes here", and just put html code in, but if I do this, I get no message content at all. I know I'm in over my head here, is there a solution? I'm slowly learning this... Thank you in anticipation...
-
echo multiple results from checkboxes...
theredking replied to theredking's topic in PHP Coding Help
Ok, I don't know what I did, but I tried it again and it worked. Thanks for your time looking at this. -
echo multiple results from checkboxes...
theredking replied to theredking's topic in PHP Coding Help
Is this what you're asking for? <input name="interest[]" type="checkbox" id="interest[]" value="Fishing" />Fishing <input name="interest[]" type="checkbox" id="interest[]" value="Golf" /> Golf <input name="interest[]" type="checkbox" id="interest[]" value="Tennis" /> Tennis <input name="interest[]" type="checkbox" id="interest[]" value="Swimming" /> Swimming -
echo multiple results from checkboxes...
theredking replied to theredking's topic in PHP Coding Help
Ok, so I got that working, but... I have another instance of checkboxes in the same form, which I want to do the same thing for. I tried to use my logic and just do: foreach ($_POST['interest'] as $value2) { echo "$value2 " ; but that didn't work... Any ideas? -
echo multiple results from checkboxes...
theredking replied to theredking's topic in PHP Coding Help
Oh ok, cool thank you!