Forum Moderators: coopster

Message Too Old, No Replies

Warning: implode(): Bad arguments.

This message appears despite the seeming success of the code?

         

oneofmany

2:05 pm on Aug 8, 2006 (gmt 0)

10+ Year Member



Below is the code this inquiry refers to. Curiously, it works well; when the user fills out the text fields and makes checkbox selections, the site sends them the echo statement and sends me (via an email) the information input into the form fields. BUT in addition to "Thank you, , for your registration. You will receive confirmation of your registration details in the mail." They get the above Warning statement "Warning: implode(): Bad arguments." Also interesting is that the same code did not trigger the warning in earlier runs? I appreciate whatever assistance you can give me.

$msg .= "InstitutionName: $_POST[InstitutionName]\n";
$msg .= "Address: $_POST[Address]\n";
$msg .= "City: $_POST[City]\n";
$msg .= "State: $_POST[State]\n";
$msg .= "Zip: $_POST[Zip]\n";
$msg .= "Registrant : $_POST[Registrant]\n";
$msg .= "Title: $_POST[Title]\n";
$msg .= "Telephone: $_POST[Telephone]\n";
$msg .= "Fax: $_POST[Fax]\n";
$msg .= "Email: $_POST[Email]\n";
$fairs = implode(',',$_POST['CCfair']);
$msg .= 'CCfair: '.$fairs.'\n';
$recipient = "";
$subject = "";
$mailheaders = "from: $_POST[Registrant]\n";
$mailheaders = "Reply-to: $_POST[Email]\n";
mail($recipient, $subject, $msg, $mailheaders);
?>

dreamcatcher

2:16 pm on Aug 8, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi oneofmany,

That error occurs when the array you are trying to implode holds no values. What you need to do is check the array is not empty before attempting to implode it.


$fairs = (!empty($_POST['CCfair'])? implode(',',$_POST['CCfair'])."\n" : '');

dc

oneofmany

2:26 pm on Aug 8, 2006 (gmt 0)

10+ Year Member



Thank you, dreamcatcher! Error message has disappeared!