Warning error: implode() [function.implode]

The part I’m having trouble with is for a series of checkboxes that answer one question. When a checkbox isn’t checked, I get the following error: Warning: implode() [function.implode]: Invalid arguments passed in /home/content/74/8926074/html/GuitarMash/contact_submitted.php on line 86

My code:

[php]

Contact body { color: #000000; }
<?php if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "[email protected]";
$email_subject = "Contact Form";
 
 
function died($error) {
    // your error code can go here
    echo "We are very sorry, but there were error(s) found with the form you submitted. ";
    echo $error."<br /><br />";
    echo "Please go back and fix these errors.<br /><br />";
    die();
}
 
// validation expected data exists
 if(!isset($_POST['firstname']) ||
	!isset($_POST['lastname']) ||
    !isset($_POST['email']) ||
    !isset($_POST['phone']) ||
	!isset($_POST['address']) ||
	!isset($_POST['addressline2']) ||
	!isset($_POST['city']) ||
	!isset($_POST['state']) ||
	!isset($_POST['zipcode']) ||
	!isset($_POST['whoplays']) ||
    !isset($_POST['comments'])) {     
}
 
$firstname = $_POST['firstname']; // required
$lastname = $_POST['lastname']; // required
$email = $_POST['email']; // required
$phone = $_POST['phone']; // required
$address = $_POST['address']; // required
$addressline2 = $_POST['addressline2']; // not required
$city = $_POST['city']; // required
$state = $_POST['state']; // required
$zipcode = $_POST['zipcode']; // not required
$whoplays= $_POST['whoplays']; //not required
$comments = $_POST['comments']; // required
 
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';

if(!preg_match($email_exp,$email)) {
$error_message .= ‘The email address you entered does not appear to be valid.
’;
}
$string_exp = “/^[A-Za-z .’-]+$/”;
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = “Form details below.\n\n”;

function clean_string($string) {
  $bad = array("content-type","bcc:","to:","cc:","href");
  return str_replace($bad,"",$string);
}

$email_message .= "First Name: ".clean_string($firstname)."\n";
$email_message .= "Last Name: ".clean_string($lastname)."\n";
$email_message .= "Email: ".clean_string($email)."\n";
$email_message .= "Phone: ".clean_string($phone)."\n";
$email_message .= "Address: ".clean_string($address)."\n";
$email_message .= "Address Line 2: ".clean_string($addressline2)."\n";
$email_message .= "City: ".clean_string($city)."\n";
$email_message .= "State: ".clean_string($state)."\n";
$email_message .= "Zip Code: ".clean_string($zipcode)."\n";
$email_message .= "Who plays guitar?".implode(',', $whoplays)."\n";
$email_message .= "Comments: ".clean_string($comments)."\n";

// create email headers
$headers = 'From: '.$email."\r\n".
'Reply-To: '.$email."\r\n" .
‘X-Mailer: PHP/’ . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>

Thank you for contacting us. We will respond shortly.

<?php } ?> [/php]

What’s line 86 and where’s the code for the implode() ?

hello Jenn,
implode() is a php function. when you try to use this function you need to pass minimum two argument where second argument must be array.
it’s working in reverse order of explode() function.
please check below link for more detail.

http://php.net/manual/en/function.implode.php

i hope this will helpful for you.
SR

Sponsor our Newsletter | Privacy Policy | Terms of Service