Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-02-21
6
Medium Priority
?
943 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 34

Accepted Solution

by:
Beverley Portlock earned 2000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
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.
Suggested Courses

886 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