PdVortex Posted January 20, 2009 Share Posted January 20, 2009 Hello, wondering if anyone can help me with an issue im having? Im trying to get this form to work it sends an e-mail and included any attachments then user wants to add to it. Problem is when they submit the form they get these errors Warning: Variable passed to each() is not an array or object in C:\Inetpub\vhosts\cavendishknights.com\httpdocs\payment.php on line 70 Warning: Variable passed to each() is not an array or object in C:\Inetpub\vhosts\cavendishknights.com\httpdocs\payment.php on line 88 Warning: Variable passed to each() is not an array or object in C:\Inetpub\vhosts\cavendishknights.com\httpdocs\payment.php on line 117 Sorry the server was unable to upload the files... This is the code im using : <?php require("class.phpmailer.php"); //Variables Declaration $name = "the Submitter"; $email_subject = 'New Escort Application!'; $email_from = "[email protected]"; $Email_to = '[email protected]'; $email_from = stripslashes($_POST['FullName']); $postcode = stripslashes($_POST['PostCode']); $fulladdress = stripslashes($_POST['FullAddress']); $MobileNumber = stripslashes($_POST['MobileNumber']); $YearsAtAddress = stripslashes($_POST['YearsAtAddress']); $PreviousAddress = stripslashes($_POST['PreviousAddress']); $Age = stripslashes($_POST['Age']); $DOB = stripslashes($_POST['DOB']); $Height = stripslashes($_POST['Height']); $Weight = stripslashes($_POST['Weight']); $Build_ = stripslashes($_POST['Build_']); $Build_2 = stripslashes($_POST['Build_2']); $Build = stripslashes($_POST['Build']); $Occupation = stripslashes($_POST['Occupation']); $EducationalBackground = stripslashes($_POST['EducationalBackground']); $Hobbies = stripslashes($_POST['Hobbies']); $Intrests = stripslashes($_POST['Intrests']); $PleaseDescribeYourself = stripslashes($_POST['PleaseDescribeYourself']); $CRB_0= stripslashes($_POST['CRB_0']); $CRB_1 = stripslashes($_POST['CRB_1']); $CRB_2 = stripslashes($_POST['CRB_2']); $Sign = stripslashes($_POST['Sign']); $Email_msg = "Message from: $from\n\nFull Address: $fulladdress\n\nPost Code: $postcode\n\nMobile Number: $MobileNumber\n\nYears At Address: $YearsAtAddress\n\nPrevious Address: $PreviousAddress\n\nAge : $Age\n\nDOB: $DOB\n\nHeight: $Height\n\nWeight: $Weight\n\nBuild : $Build_\n\nBuild: $Build_2\n\nBuild: $Build\n\nOccupation: $Occupation\n\nEducational Background : $EducationalBackground\n\nHobbies : $Hobbies\n\nIntrests : $Intrests\n\nPlease Describe Yourself : $PleaseDescribeYourself\n\nI have a current CRB form and attach a copy and payment of 7.50 (Post only) : $CRB_0\n\nI do not have a current CRB form and attach payment of 28.00 (Post or E-mail) : $CRB_1\n\nI am a foreign national and attach paymentof 36.00 (Post or E-mail) : $CRB_2\n\nSign : $Sign\n\n"; $dir = "uploads/$filename"; chmod("uploads",0777); $attachments = array(); checkType(); //------Check TYPE------\\ function checkType() { while(list($key,$value) = each($_FILES[images][type])){ strtolower($value); if($value != "image/jpeg" AND $value != "image/pjpeg" AND $value != "") { exit('Sorry , current format is <b>'.($value).'</b> ,only Jpeg or jpg are allowed.'); } } checkSize(); } //-------END OF Check TYPE--------\\ //---CheckSizeFunction ---\\ function checkSize(){ global $result, $MV ,$errors,$BackLink; while(list($key,$value) = each($_FILES[images][size])) { $maxSize = 8000000; if(!empty($value)){ if ($value > $maxSize) { echo"Sorry this is a very big file .. max file size is $maxSize Bytes = 5 MB"; exit(); } else { $result = "File size is ok <br>"; } } } uploadFile(); } //-------END OF Check Size--------\\ //==============upload File Function============\\ function uploadFile() { global $attachments; while(list($key,$value) = each($_FILES[images][name])) { echo("just trying to send it!!!"); if(!empty($value)) { $filename = $value; array_push($attachments, $filename); $dir = "uploads/$filename"; chmod("uploads",0777); $success = copy($_FILES[images][tmp_name][$key], $dir); } } if ($success) { echo " Files Uploaded Successfully<BR>"; SendIt(); }else { exit("Sorry the server was unable to upload the files..."); } } //======================================================================== PHP Mailer With ATtachment Func ===============================\\ function SendIt() { global $attachments,$name,$Email_to,$Email_msg,$email_subject,$email_from; $mail = new PHPMailer(); $mail->IsSMTP();// send via SMTP $mail->Host = "smtp"; // SMTP servers $mail->SMTPAuth = false; // turn on/off SMTP authentication $mail->From = $email_from; $mail->FromName = $name; $mail->AddAddress($Email_to); $mail->AddReplyTo($email_from); $mail->WordWrap = 50;// set word wrap foreach($attachments as $key => $value) { //loop the Attachments to be added ... $mail->AddAttachment("uploads"."/".$value); } $mail->Body = $Email_msg."Name : ".$name."\n"; $mail->IsHTML(false);// send as HTML $mail->Subject = $email_subject; if(!$mail->Send()) { echo "Message was not sent <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit; } echo "Message has been sent"; // after mail is sent with attachments , delete the images on server ... //foreach($attachments as $key => $value) {//remove the uploaded files .. // unlink("uploads"."/".$value); //} } ?> Line 70 is this : strtolower($value); Line 88 is this : { Line 117 is this : { Hopefully someone can help me i been at this for hours and i bet its something really simple. Thanks for any help in advance Link to comment https://forums.phpfreaks.com/topic/141594-sending-attachments-via-e-mail/ Share on other sites More sharing options...
PdVortex Posted January 20, 2009 Author Share Posted January 20, 2009 Anyone? Disparate now Link to comment https://forums.phpfreaks.com/topic/141594-sending-attachments-via-e-mail/#findComment-741184 Share on other sites More sharing options...
PdVortex Posted January 20, 2009 Author Share Posted January 20, 2009 Still no-one? I will bump this message every so often to make sure people can still view it! Link to comment https://forums.phpfreaks.com/topic/141594-sending-attachments-via-e-mail/#findComment-741293 Share on other sites More sharing options...
PdVortex Posted January 20, 2009 Author Share Posted January 20, 2009 anyone? please help Link to comment https://forums.phpfreaks.com/topic/141594-sending-attachments-via-e-mail/#findComment-741560 Share on other sites More sharing options...
jjacquay712 Posted January 20, 2009 Share Posted January 20, 2009 im not sure how to send an attachment with php... not familiar with the SMTP protocol, but maybe add something to the header function when your sending the email. Link to comment https://forums.phpfreaks.com/topic/141594-sending-attachments-via-e-mail/#findComment-741569 Share on other sites More sharing options...
PdVortex Posted January 21, 2009 Author Share Posted January 21, 2009 Thanks for you reply but. . . 1 what do you mean? 2 its something to do with the array? Link to comment https://forums.phpfreaks.com/topic/141594-sending-attachments-via-e-mail/#findComment-742018 Share on other sites More sharing options...
PdVortex Posted January 21, 2009 Author Share Posted January 21, 2009 Im guessing nobody knows why this is happening then Link to comment https://forums.phpfreaks.com/topic/141594-sending-attachments-via-e-mail/#findComment-742196 Share on other sites More sharing options...
prcollin Posted January 21, 2009 Share Posted January 21, 2009 Im guessing nobody knows why this is happening then can you highlight the lines of error so i can look around them because i am at work without an editor and i dont want to count them Link to comment https://forums.phpfreaks.com/topic/141594-sending-attachments-via-e-mail/#findComment-742236 Share on other sites More sharing options...
PdVortex Posted January 21, 2009 Author Share Posted January 21, 2009 Hey thanks for your reply, i have already said what the lines are here they are again : Line 70 is this : strtolower($value); Line 88 is this : { Line 117 is this : { Sorry i don't know how to highlight the code. Thanks for any help in advance Link to comment https://forums.phpfreaks.com/topic/141594-sending-attachments-via-e-mail/#findComment-742376 Share on other sites More sharing options...
deeceemorris Posted January 21, 2009 Share Posted January 21, 2009 I'm having the same problem with the same error messages with a similar script. I think your line numbers are off: I think the offending code actually is: while(list($key,$value) = each($_FILES[images][type])) while(list($key,$value) = each($_FILES[images])){ while(list($key,$value) = each($_FILES[images][name])){ Link to comment https://forums.phpfreaks.com/topic/141594-sending-attachments-via-e-mail/#findComment-742539 Share on other sites More sharing options...
PdVortex Posted January 21, 2009 Author Share Posted January 21, 2009 Any solution? Or just more questions? Link to comment https://forums.phpfreaks.com/topic/141594-sending-attachments-via-e-mail/#findComment-742636 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.