Solved

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

Posted on 2011-02-21
6
918 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

777 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