Foros del Web » Programando para Internet » PHP » Frameworks y PHP orientado a objetos »

Bad arguments en function implode... Clase PliggMailer

Estas en el tema de Bad arguments en function implode... Clase PliggMailer en el foro de Frameworks y PHP orientado a objetos en Foros del Web. Hola por aquí, necesito me ayuden con algo, pues no entiendo mucho de PHPOO Tengo un sitio montado en Pligg y trae la opción de ...
  #1 (permalink)  
Antiguo 05/12/2008, 09:19
Avatar de rogertm
Mod->Cuba
 
Fecha de Ingreso: julio-2005
Ubicación: /home/Cuba/Habana/rogertm/
Mensajes: 2.922
Antigüedad: 18 años, 9 meses
Puntos: 638
Pregunta Bad arguments en function implode... Clase PliggMailer

Hola por aquí, necesito me ayuden con algo, pues no entiendo mucho de PHPOO

Tengo un sitio montado en Pligg y trae la opción de enviar los artículos a un amigo, pero no funciona, mandaba este error:

Warning: implode() [function.implode]: Bad arguments. in /home/public_html/libs/mailer.php on line 31


Este es el código original:

Código php:
Ver original
  1. <?php
  2. class PliggMailer{
  3.  
  4.     var $subject = '';
  5.     var $body = '';
  6.     var $from = '';
  7.     var $to = '';
  8.  
  9.     function PliggMailer($subj = '', $body = '', $from = '', $to = '', $cc = '', $bcc = ''){
  10.  
  11.         if($subj != ''){$this->subject = $subj;}
  12.         if($body != ''){$this->body = $body;}
  13.         if($from != ''){$this->from = $from;}
  14.         if(!is_array($to)){$to[] = $to;}
  15.         if(count($to) == 0){$this->to = $to;}
  16.         if(!is_array($to)){$to[] = $to;}
  17.         if(count($to) == 0){$this->to = $to;}
  18.         if(!is_array($to)){$to[] = $to;}
  19.         if(count($to) == 0){$this->to = $to;}
  20.  
  21.     }
  22.  
  23.     function send(){
  24.  
  25.         if($this->from != ''){
  26.             $headers = 'From: ' . $this->from;
  27.         } else {
  28.             $headers = '';
  29.         }
  30.  
  31.         $send_to = implode(',', $this->to);
  32.  
  33.         if(mail($send_to, $this->subject, $this->body, $headers)){
  34.             return true;
  35.         } else {
  36.             return false;
  37.         }
  38.  
  39.     }
  40. }
  41. ?>
y lo que hice fue cambiar este línea var $to = ''; por var $to = array(''); (la linea 7). Ya no me da el error, pero tampoco envía el mensaje

Que pasa???

Gracias mil de antemano
__________________
Friki y Blogger por Cuenta Propia:213
Twenty'em: Theming is Prose
  #2 (permalink)  
Antiguo 05/12/2008, 09:25
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: Bad arguments en function implode... Clase PliggMailer

Pues tanto de PHP OO, no es, si te fijas la linea 31 dice: $send_to = implode(',', $this->to);, si en algun momento tu defines $to como un string, te va a dar el error, te recomiendo hacer algo así:
Código php:
Ver original
  1. if(is_array($this->to)) {
  2.     $send_to = implode(',', $this->to);
  3. } else {
  4.     $send_to = $this->to;
  5. }

Saludos.
  #3 (permalink)  
Antiguo 05/12/2008, 10:07
Avatar de rogertm
Mod->Cuba
 
Fecha de Ingreso: julio-2005
Ubicación: /home/Cuba/Habana/rogertm/
Mensajes: 2.922
Antigüedad: 18 años, 9 meses
Puntos: 638
Respuesta: Bad arguments en function implode... Clase PliggMailer

Gracias GatorV... pero siguen sin llegar los mensajes
__________________
Friki y Blogger por Cuenta Propia:213
Twenty'em: Theming is Prose
  #4 (permalink)  
Antiguo 05/12/2008, 11:04
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: Bad arguments en function implode... Clase PliggMailer

Pues eso creo ya no es problema de tu clase, más bien revisa si mail() le esta entregando a tu servidor SMTP el mail correctamente, revisa los logs de tu SMTP server y ahi puedes ver el control de transacciones.

Saludos.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:43.