Solved

error log: PHP Notice:  Only variable references should be returned by reference

Posted on 2011-02-21
6
925 Views
Last Modified: 2012-05-11
[Sat Feb 05 10:03:03 2011] [client 76.168.200.119] PHP Notice:  Only variable references should be returned by reference in /home/derm/fpdf/tutorial/Mail_Mime/mime.php on line 356, referer: https://midvalleydermatology.com/history/historyform.php

code error is referring to:

function &_addMixedPart()
    {
        $params['content_type'] = 'multipart/mixed';
        return new Mail_mimePart('', $params);
    }
0
Comment
Question by:phillystyle123
6 Comments
 
LVL 1

Expert Comment

by:DoCBReeD
ID: 34948054
Are you trying to generate a pdf and email it?
0
 

Author Comment

by:phillystyle123
ID: 34948344
yes - to clarify,the script already works -i'm just trying to figure out why i'm getting these log errors
0
 
LVL 16

Expert Comment

by:sjklein42
ID: 34948832

You can only return variables by reference, not the result of a statement.

Note the "&" before the function name.

http://php.net/manual/en/language.references.return.php

Try this:

function &_addMixedPart()
    {
        $params['content_type'] = 'multipart/mixed';
        $return = new Mail_mimePart('', $params);
        return $return;
} 

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 34

Accepted Solution

by:
Beverley Portlock earned 500 total points
ID: 34949493
This little bug has been in the Mail_mime package for years. Just ignore it.
0
 
LVL 1

Expert Comment

by:DoCBReeD
ID: 34949530
Try the following w/out using mime.  

		$pdfdoc = $pdf->Output("example.pdf", 'S');

    
	$to = "Youremail@yourdot.com";
	$from = "Youremail@yourdot.com";
	$subject = "Subject";
	$message = "<p>Please see the attachment.</p>";
	$separator = md5(time());
	$eol = PHP_EOL; 
	$filename = "example.pdf";
    
	$attachment = chunk_split(base64_encode($pdfdoc));
	$headers = "From: ".$from.$eol;
	$headers .= "MIME-Version: 1.0".$eol;
	$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"".$eol.$eol;
	$headers .= "Content-Transfer-Encoding: 7bit".$eol;
	$headers .= "This is a MIME encoded message.".$eol.$eol;
	$headers .= "--".$separator.$eol;
	$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
	$headers .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
	$headers .= $message.$eol.$eol;
	$headers .= "--".$separator.$eol;
	$headers .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol;
	$headers .= "Content-Transfer-Encoding: base64".$eol;
	$headers .= "Content-Disposition: attachment".$eol.$eol;
	$headers .= $attachment.$eol.$eol;
	$headers .= "--".$separator."--";

	if(mail($to, $subject, "$message", $headers)){
		?>
	<script type="text/javascript"><!--
    alert("Alert message!");
    window.location = "index.php";
    --></script>
	<?php
}
?>

Open in new window

0
 

Author Closing Comment

by:phillystyle123
ID: 34975701
Thanks!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question