2

I have added an email contact form to my site using a guide from here:

https://www.boutell.com/newfaq/creating/email.html

It works fine, except for the following error message that appears on the page:

Warning: implode(): Invalid arguments passed in /var/www/vip6/sites/vip4092987/httpd/htdocs/email.php on line 130

And the offending code:

<?php
        # Shift back into PHP mode for a moment to display
        # the error message, if there was one
        if (count($messages) > 0) {
                $message = implode("<br>\n", $messages);
                echo("<h3>$message</h3>\n");
        }
?>

I've tried contacting the author site without any response, how do I resolve this?

2
  • Run var_dump($messages); to verify it contains what you think it contains. Commented Jul 25, 2018 at 16:44
  • As others have said, check what $messages contains. Most likely it only has 1 element, and since php is (mostly) dynamically typed its not going to be seen as an array when passed into implode(). Commented Jul 25, 2018 at 17:17

1 Answer 1

2

Implode function need an array as the second argument, looks like in your case $messages variable is not an array

Check what messages content is

var_dump($messages)

Also can try to cast type:

$message = implode("<br>\n", (array)$messages);

But proper solution depends on an actual value of $messages variable

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for your answer, adding (array) has resolved the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.