Welcome Guest, Not a member yet? Register   Sign In
Invalid argument supplied for foreach() in Email.php
#1

[eluser]zoreli[/eluser]
Hi

I use CI 2.0.2 version

I have a simple register form with 5 fields. When trying to register, form is submitted, but I get the following error.

A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: libraries/Email.php


Line Number: 111

Error occurs when I try to send an e-mail to the new user, that just register.


line 111 is Email.php is the following:

foreach ($config as $key => $val)

Anyone can point me to the solution of this problem?

Regards,Zoreli

#2

[eluser]skunkbad[/eluser]
[quote author="zoreli" date="1341875441"]Hi

I use CI 2.0.2 version

I have a simple register form with 5 fields. When trying to register, form is submitted, but I get the following error.

A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: libraries/Email.php


Line Number: 111

Error occurs when I try to send an e-mail to the new user, that just register.


line 111 is Email.php is the following:

foreach ($config as $key => $val)

Anyone can point me to the solution of this problem?

Regards,Zoreli

[/quote]

Are you extending the mail class? The email class by itself should never have this error.
#3

[eluser]zoreli[/eluser]
Hi skunkbad

No, I am not extending it. I downnload the CI 2.1.2 and I replace that file, with the new one and I get the same error. The strange thing is that e-mail is sent successully....But why on earth am getting that error message remain a mystery for me.

Regards,Zoreli
#4

[eluser]Aken[/eluser]
We need to know any relevant code, otherwise we're guessing.
#5

[eluser]marjune[/eluser]
first of all what is the value of the variable
Code:
$config
#6

[eluser]skunkbad[/eluser]
[quote author="marjune" date="1341897020"]first of all what is the value of the variable
Code:
$config
[/quote]

This is a good point. If the email class is initialized with $config as anything but an array, the OP's error would be appropriate.
#7

[eluser]zoreli[/eluser]
Hi

Sorry about the delay of responding on the main question here, the value of $config variable.

using the print_r, the variable of the $config returns the following:

Reply-To: my_valiehere.... Return-Path: my_value_here... From: my_value_herel...

Hope this helps
#8

[eluser]zoreli[/eluser]
Shameless bump :cheese:
#9

[eluser]InsiteFX[/eluser]
This is telling me that you have not setup the $config array for the email class.

CodeIgniter Users Guide - Email Class
#10

[eluser]JoostV[/eluser]
You have either loaded the email library like so
Code:
$this->load->library('email', $config);
or called
Code:
$this->email->initialize($config);

$config needs to be an array of on or more options to be set, for instance
Code:
$config = array('mailtype' => 'html');

Judging from the error you are passing a string, not an array.

Options that can be set in $config can be found in the user guide.




Theme © iAndrew 2016 - Forum software by © MyBB