Click to See Complete Forum and Search --> : Script error


LiL|aaron
09-01-2006, 03:34 PM
Hi,

I wrote this but nothing seems to happen, no errors.. no text nothing! nothing wrong with the server or settings in the php.ini because i have other scripts like this working... i think i might be a type error or something... just cant see any ....


<?

error_reporting(E_ALL);
require("/quest/conf/mysql.inc.php");
require("/quest/conf/mail.inc.php");

$today = date("Y-m-d");

$query = mysql_query("SELECT DISTINCT * FROM daily_devotions WHERE `date` <= '$today'") or die(mysql_error());
$rows = mysql_fetch_array($query);
echo '<b>The Daily Devotion For '.$rows['date'].'</b><BR><BR>';
echo '<b>Title:</b> '.$rows['name'].'<BR><BR>';
echo '<b>Devotion:</b><BR><BR>'.$rows['text'].'<BR><BR>';

$query2 = mysql_query("SELECT DISTINCT * FROM mail_devo ORDER BY email") or die(mysql_error());
$row = mysql_fetch_array($query2);

$title = 'Daily Devotionals';
$content = 'Dear '.$row['name'].',<BR><BR>A New Daily Devotional Is Available!<BR>Called: '.$rows['name'].' <BR><BR>Please Goto <a href="http://www.questministries.com" target="_blank">http://www.questministries.com</a><BR><BR>Kind Regards,<BR>Quest Ministries';
$subject = $title;
$message = $content;
$headers = "From: $from_address\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

foreach ($row['email'] as $addr)
{
print '&nbsp&nbsp&nbspSent email to ' . $addr . '<br>';
mail($addr, $subject, $message, $headers);

}

?>


Thanks
Aaron

chesemonkyloma
09-01-2006, 04:08 PM
Try replacing <? with <?php
at the beginning of the script i think, it doesnt always work.

NogDog
09-01-2006, 04:30 PM
Depending on your PHP configuration, you might need to add the following line at the start of your script to have errors displayed:

ini_set("display_errors", "1");

LiL|aaron
09-02-2006, 12:44 AM
Sorted it!

<?php

ini_set("display_errors", "1");
require("conf/mysql.inc.php");
require("conf/mail.inc.php");

$today = date("Y-m-d");

$query = mysql_query("SELECT DISTINCT * FROM daily_devotions WHERE `date` <= '$today'") or die(mysql_error());
$rows = mysql_fetch_array($query);
echo '<b>The Daily Devotion For '.$rows['date'].'</b><BR><BR>';
echo '<b>Title:</b> '.$rows['name'].'<BR><BR>';
echo '<b>Devotion:</b><BR><BR>'.$rows['text'].'<BR><BR>';

$query2 = mysql_query("SELECT DISTINCT * FROM mail_devo ORDER BY email") or die(mysql_error());
$row = mysql_fetch_array($query2);

$title = 'Daily Devotionals';
$content = 'Dear '.$row['name'].',<BR><BR>A New Daily Devotional Is Available!<BR>Called: '.$rows['name'].' <BR><BR>Please Goto <a href="http://www.questministries.com" target="_blank">http://www.questministries.com</a><BR><BR>Kind Regards,<BR>Quest Ministries';
$subject = $title;
$message = "$content";
$headers = "From: $from_address\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

$query = mysql_query("SELECT DISTINCT * FROM mail_devo ORDER BY email");
while($row = mysql_fetch_array($query)){
$addr = $row['email'];
print '&nbsp&nbsp&nbspSent email to ' . $addr . '<br>';
mail($addr, $subject, $message, $headers);
}


?>

I only got 1 last questions... how would i make sure $row['email'] has no duplicate entre's... like

me@yahoo.com
you@yahoo.com
me@yahoo.com

thats how its displayed above... so how would i make it so me@yahoo.com doesnt show twice.

Thanks
Aaron

NogDog
09-02-2006, 01:13 AM
Since you're only using the 'email' column from your results, only select it:

$query = mysql_query("SELECT DISTINCT email FROM mail_devo ORDER BY email");