Jump to content

rickbond79

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Everything posted by rickbond79

  1. Hi there, I have a simple question - is it possible to send out an html email containing PHP/MySQL code so that when the user receives the email it checks the date and serves up content from a database? I have created a page that works fine online, but when I try to email the page, it doesn't work from within the user's email client (such as outlook, or gmail). When I look at the raw email source, it looks like the PHP code isn't getting executed by the email program. If anyone knows a reason or workaround, I would appreciate it! Thanks in advance, Rick <?php $day = date("Y-m-d"); // Connects to your Database mysql_connect("empowermentoftheday.com", "username", "password") or die(mysql_error()) ; mysql_select_db("etd_emails") or die(mysql_error()) ; if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $query = sprintf("SELECT * FROM daily WHERE date = '%s'", mysql_real_escape_string($day)); // Perform Query $Recordset1 = mysql_query($query); // Check result // This shows the actual query sent to MySQL, and the error. Useful for debugging. if (!$Recordset1) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die($message); } $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="description" content="Free inspirational Picture of the Day as well as a Free daily Wellness Break. Start your day off right and Empower Yourself Today. Empowerment of the Day is meant to inpire you each and every day and is brought to you by the Remakable Success Group Team.Empower Yourself Today." /> <meta name="keywords" content="inspirational quote, picture of the day, wellness quote, inspirational saying, inspirational story, today's wellness break, empowerment, empower yourself, empowerment of the day, health tip, wellness tip" /> <title>Empowerment Of The Day</title> </head> <body marginheight="0" marginwidth="0" topmargin="0" leftmargin="0"> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="100%" align="center"> <div style="background:#DBAE13"> <img src="http://www.empowermentoftheday.com/email/images/header.jpg" alt="Empowerment of the Day" width="650" height="77" /></div> <div> <table width="650" border="0" cellpadding="0" cellspacing="0"> <tr> <td align="center" valign="middle"><img src="http://www.empowermentoftheday.com/email/images/message2.jpg" alt="Picture of the Day" width="306" height="34" vspace="15" /></td> </tr> <tr> <td align="center" valign="middle"> <table border="0" cellspacing="0" cellpadding="5" bgcolor="#000000"> <tr height="10px"> <td height="10px"></td> <td height="10px"></td> <td height="10px"></td> </tr> <tr> <td> </td> <td><img src="http://www.empowermentoftheday.com/email/images/photos/<?php echo $row_Recordset1['photo']; ?>" alt="Picture of the Day" /></td> <td> </td> </tr> <tr> <td> </td> <td align="center"> <div><font color="#FFFFFF" face="Helvetica, Arial, sans-serif"><?php echo $row_Recordset1['quote']; ?></font></div> </td> <td> </td> </tr> </table> </td> </tr> <tr> <td align="center" valign="middle"> <img src="http://www.empowermentoftheday.com/email/images/message3.jpg" alt="Today's Wellness Break" width="360" height="44" vspace="15" /></td> </tr> <tr> <td align="center" valign="middle"><p><font color="#000000" face="Helvetica, Arial, sans-serif"><?php echo $row_Recordset1['wellness']; ?><br> <br> </font></p></td> </tr> </table> <script language="JavaScript1.2" type="application/javascript"> /* Disable right click script II (on images)- By Dynamicdrive.com For full source, Terms of service, and 100s DTHML scripts Visit http://www.dynamicdrive.com */ var clickmessage="Right click disabled on images!" function disableclick(e) { if (document.all) { if (event.button==2||event.button==3) { if (event.srcElement.tagName=="IMG"){ alert(clickmessage); return false; } } } else if (document.layers) { if (e.which == 3) { alert(clickmessage); return false; } } else if (document.getElementById){ if (e.which==3&&e.target.tagName=="IMG"){ alert(clickmessage) return false } } } function associateimages(){ for(i=0;i<document.images.length;i++) document.images[i].onmousedown=disableclick; } if (document.all) document.onmousedown=disableclick else if (document.getElementById) document.onmouseup=disableclick else if (document.layers) associateimages() </script> </div> <div style="background:#D0A615"> <img src="http://www.empowermentoftheday.com/email/images/footer.jpg" alt="Copyright 2010 Remarkable Success Group Inc. Design by Ortega.ca" width="650" height="74" border="0" usemap="#Map" /> <map name="Map"><area shape="rect" coords="456,28,617,55" href="http://www.ortega.ca" alt="Design by Ortega.ca" target="_blank"></map> </map></div> <!-- GOOGLE ANALYTICS --> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-2910054-6']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> </td> </tr> </table> </body> </html> <?php mysql_free_result($Recordset1); ?>
  2. Cheers friend, that's got it! If you're interested here is the live version: http://www.vanierbia.com/vanier-business-directory2.php
  3. Thanks Andy-H, Tried replacing the code, and I'm getting a blank page - nothing seems to be loading in between the body tags. Any ideas?
  4. Hey people! I hope you can help me, I have a script that searches a database and returns a list of results. The script works great, except if the user doesn't enter any search term. It looks like the script uses an exit; and then the rest of the html page will not load. I understand why this happens but not how to fix it. Here's the code, look for the comment "// PROBLEM HERE" Any help would be appreciated! Cheers! <?php // Get the search variable from URL $var = @$_GET['q'] ; $trimmed = trim($var); //trim whitespace from the stored variable // PROBLEM HERE check for an empty string and display a message. if ($trimmed == "") { echo "<p>Please enter a search term.</p>"; exit; } // rows to return $limit=300; // check for a search parameter if (!isset($var)) { echo "<p>We don't seem to have a search parameter!</p>"; exit; } // Build SQL Query $query = "select * from directory where name like \"%$trimmed%\" order by name"; // EDIT HERE and specify your table and field names for the SQL query $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); // If we have no results, offer a google search as an alternative if ($numrows == 0) { echo "<p>Sorry, your search: "" . $trimmed . "" returned zero results.</p>"; } // next determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; } // get results $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query"); // display what the person searched for echo "<p>You searched for: "" . $var . ""</p>"; // begin to show results set $count = 1 + $s ; // now you can display the results returned while ($row= mysql_fetch_array($result)) { $title = $row["name"]; $address = $row["address"]; $phone = $row["phone"]; echo " <table class='results'> <tr> <td valign='top'><span class='intro'>$count.) </span></td> <td valign='top'><span class='intro'>$title</span><br /> $address<br /> Phone: $phone</td> </table> <hr size='1' style='padding-top:0; padding-bottom:0'> " ; $count++ ; } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.