ob_start();
  include "broad_prev.php";
  $message = ob_get_contents();
  ob_end_clean();

i have used the code above to get the contents of my php page to display in a newsletter thst is emailed out to the mailing list.

it works to apoint but no images are sent through with the email just the text. could this be a problem with how the images are stored on the page it is putting into the email.

the code for the page which is getting emailed looks like this

<body>
<?php
include"db.php";

$con = mysql_pconnect("$xxxxx","$xxxxx","$xxxxx") 
	or die ("QUERY ERROR: ".mysql_error());

$db = mysql_select_db($xxxxxx, $xxxxxx)
	or die("QUERY ERROR: ".mysql_error());
?>
<table width="900" border="0" align="center" cellpadding="0" cellspacing="5">
    <tr>
        <td height="95" colspan="2" scope="col"><img src="layout/BroadsheetSample/broadhead.jpg" width="900" height="150" /></td>
    </tr>
    <tr>
        <td height="25" colspan="2" scope="col"><span class="title"><?php echo ($broad_topictitle1); ?></span></td>
    </tr>
    <tr>
        <th width="23%" height="200" scope="col"><div align="left">
            <p>

					<?php
						
					$query = "SELECT broad1 FROM images_broad";
					$result=mysql_query($query);

					while($row=mysql_fetch_array($result, MYSQL_ASSOC)){
					echo '<img src="'.$row['broad1'].'"/>';
					}
						      
					?>
			
            <p>&nbsp;</p>
        </div></th>
        <td width="77%" scope="col"><table width="99%" border="0" cellpadding="10" cellspacing="0">
            <tr>
                <td align="left" valign="top"><span class="mainTxt"><?php echo  ($broad_messagebody1); ?></span></td>
                <!-- End Image 1 -->
            </tr>
        </table>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p></td>
    </tr>
    <tr>
        <td height="28" colspan="2" scope="col"><span class="title"><?php echo ($broad_topictitle2); ?></span></td>
    </tr>
    <tr>
        <th height="95" scope="col"><div align="left">
            		<?php
						
					$query = "SELECT broad2 FROM images_broad";
					$result=mysql_query($query);

					while($row=mysql_fetch_array($result, MYSQL_ASSOC)){
					echo '<img src="'.$row['broad2'].'"/>';
					}
					
						      
					?>
            <p><br />
            </p>
        </div></th>
        <td scope="col"><table width="99%" border="0" cellpadding="10" cellspacing="0">
                <tr>
                    <td align="left" valign="top"><span class="mainTxt"><?php echo ($broad_messagebody2); ?></span></td>
                    <!-- End Image 1 -->
                </tr>
				
            </table>
                <p>&nbsp;</p>
                <p>&nbsp;</p>
                <p>&nbsp;</p>
                <p>&nbsp;</p>
                <p>&nbsp;</p></td>
    </tr>
    <tr>
        <td colspan="2" scope="col"><img src="layout/BroadsheetSample/broadfoot.jpg" width="900" height="150" /></td>
    </tr>
    
    <tr>
        <td height="13" colspan="2" scope="col"><div align="justify"><span class="style1">Linacre Voice is a monthly bulletin from LinacreOne Community Partnership 140-142 Linacre Road Litherland L21 8JU Tel: (0151) 922 4898 Open Monday - Thursday 10:00am - 4:00pm <font size="\&quot;1\&quot;"></font></span> </div></td>
    </tr>
</table>
</body>
</html>

if anyone could help it would be much appreciated.

Recommended Answers

All 7 Replies

The images aren't working because you are using relative paths. You have to use absolute paths(with the domain included) to be viewable outside of the host domain.

how can i get the mysql images to display in the newsletter?

how would i get the absolute path for these.

yes that would work if the images where stored within the same folders as the website but as the images are being uploaded by the user and stored in the mysql data base.

i used php to get the path to the directory where the images are stored but how can i use this to display the images that held in the mysql db.

If the images are actually being stored in the database, I don't think you can do it. The recipient's PC would need permission to access your database and that isn't normally done.

If the images are in a folder on your webserver and the path to the image is stored in the database, you can generate the e-mail message in the same way as you would a normal web page - that is, assuming your e-mail message is in HTML.

most of the body is dynamically created from user inputs but the images are uploaded from an upload page then stored in an mysql database. only the relative path to the uploaded images is stored.

would it be possible to store the absolute path to the image in the database then use the include function in php to access the db and retrieve the images needed for the email.

surly this has been done before i cannot be the first person to try and send images from a mysql db in an email. :-(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.