bonjour,
j'ai un petit code:
Mon erreur est :
Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in xxxx on line 290
c'est ce lui ci: $f= new Attachemail();
j'ai meme essayer d;enlever le () mais ce ne marche toujours pas
Merci pour votre reponse
j'ai un petit code:
if(isset ($_POST['sujet2']) &&!empty ($_POST['sujet2'])&& !isset ($load)&&!isset($xong))
{
$sujet = $_POST['sujet2'];
$tabmailok = $_POST['hide2'];
//////Fonction pour attacher email ecrit en object////////////////////////////////////////
class Attachemail
{
var $aattach= array();
//var $info;
//var $fr =array();var $dnt =array(); var $rep =''; var $ret='';
function Body( $body )
{
$this->body= $body;
}
function Attach( $filename, $filetype='application/x-unknown-content-type', $disposition = "inline" )
{
// TODO : si filetype="", alors chercher dans un tablo de MT connus / extension du fichier
$this->aattach[] = $filename;
$this->actype[] = $filetype;
$this->adispo[] = $disposition;
}
function sp($info)
{$this->info =$info; }
function _build_headers()
{
// creation du header mail
$this->headers= 'From: $this->info'. "\n";
$this->headers.='Reply-To: $this->info'."\n";
//$this-> headers .= 'Mime-Version: 1.0'."\r\n";
$this->headers.='Content-type: text/html; charset=utf-8'."\r\n";
$this->headers.='Disposition-Notification-To:$this->info'."\r\n";
$this->headers.='Return-Receipt-To: $this->info'."\r\n";
$this->headers.="\r\n";
}
function Get()
{
$this->_build_headers();
if( sizeof( $this->aattach > 0 ) )
{
$this->_build_attachement();
$this->body= $this->body . $this->attachment;
}
$mail = $this->headers;
$mail .= "\n$this->body";
return $mail;
}
function _build_attachement()
{
$this->boundary= "------------" . md5( uniqid("myboundary") ); // TODO : variable bound
$this->headers .= "MIME-Version: 1.0\nContent-Type: multipart/mixed;\n boundary=\"$this->boundary\"\n\n";
$this->fullBody = "C'est un multi-part message in MIME format.\n--$this->boundary\nContent-Type: text/plain; charset=us-ascii\nContent-Transfer-Encoding: 7bit\n\n" . $this->body ."\n";
$sep= chr(13) . chr(10);
$ata= array();
$k=0;
// a chaue fichier attacher, fait
for( $i=0; $i < sizeof( $this->aattach); $i++ )
{
$filename = $this->aattach[$i];
$basename = basename($filename);
$ctype = $this->actype[$i]; // content-type
$disposition = $this->adispo[$i];
if( ! file_exists( $filename) ) {
echo "Class Mail, method attach :ne pas trouver le fichier "; exit;
}
$subhdr= "--$this->boundary\nContent-type: $ctype;\n name=\"$basename\"\nContent-Transfer-Encoding: base64\nContent-Disposition: $disposition;\n filename=\"$basename\"\n";
$ata[$k++] = $subhdr;
// non encoded line length
$linesz= filesize( $filename)+1;
$fp= fopen( $filename, 'r' );
$data= base64_encode(fread( $fp, $linesz));
fclose($fp);
$ata[$k++] = chunk_split( $data );
}
$this->attachment= implode($sep, $ata);
}
function Send()
{
// build the headers
$this->_build_headers();
// include attached files
if( sizeof( $this->aattach > 0 ) )
{
$this->_build_attachement();
$body = $this->fullBody . $this->attachment;
}
// envoie du mail aux destinataires principal
for( $i=0; $i< count($this->sendto); $i++ ) {
{
$this->des="<br><a href=\"http://www.pky-energie.com/mail/desincription.php?code=".$this->sendto[$i]."\">Si vous ne voulez plus recevoir ce message,cliquez ici</a></br>\n";
//mail($this->sendto[$i], $this->msubject,$body, $this->headers
mail($this->sendto[$i], $this->suj,body.$this->des, $this->headers);
if($i==count($this->sendto)-1)
{unset($_SESSION['ten']);unset ($_SESSION['txt']);unset ($_SESSION['hide2']);unset($_SESSION['sujet2']);$xong='xong';
echo 'Votre email a ete envoyer';
}
// TODO : trmt res
}
}
function To( $to )
{
// TODO : test validité sur to
if( is_array( $to ) )
$this->sendto= $to;
else
$this->sendto[] = $to;
}
function Sujet($suj)
{
$this->suj=$suj;
}
}
//echo 'bb';
$f= new Attachemail(); // create the mail
$f->Body($edit); // set the body
$f->sp("spky.fr<info@spky.fr>");
$f->To($tabmailok);
$f->Sujet($sujet);
if ("$NomFichier_name"!="")
{
copy("$NomFichier","../upload/$NomFichier_name");
$f->Attach( "../upload/$NomFichier_name", "application/octet-stream" );
}
$f->Send();
if ("$NomFichier_name"!="") {
Unlink("../upload/$NomFichier_name"); }
/*mailspkyb('spky','info@spky.fr',$tabmailok[$i],$sujet,$edit,'www.spky.fr');*/
}
elseif(empty ($_POST['sujet2']))
{$erreur.= "Veuillez rentrer votre sujet";
}
}
Mon erreur est :
Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in xxxx on line 290
c'est ce lui ci: $f= new Attachemail();
j'ai meme essayer d;enlever le () mais ce ne marche toujours pas

Merci pour votre reponse