|
Posted by paul814 on 12/27/07 18:35
On Dec 26, 9:10 am, Evil Otto <zburn...@gmail.com> wrote:
> On Dec 24, 1:06 pm, paul...@excite.com wrote:
>
>
>
> > On Dec 24, 12:40 pm, Iván Sánchez Ortega <ivansanchez-...@rroba-
>
> > escomposlinux.-.punto.-.org> wrote:
> > > paul...@excite.com wrote:
> > > > If I echo $txt on the page....I get:
> > > > PLEASE DO NOT REPLY TO THIS EMAIL, THIS IS NOT A VALID EMAIL ADDRESS
>
> > > 'Cause you're overwriting $txr ...
>
> > > Please stop trying things blindly, and start thinking about what your
> > > program is doing.
>
> > > --
> > > ----------------------------------
> > > Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
>
> > > Now listening to: Sigur Rós - Takk... (2005) - [5] Sé Lest (8:40)
> > > (96.000000%)
>
> > So what do I need to do to put editorialdate, editorialname, and
> > editorialcomments in an email?
>
> A better way to do this would be the following:
>
> $txt = "PLEASE DO NOT REPLY TO THIS EMAIL, THIS IS NOT A
> VALID EMAIL ADDRESS";
>
> /* do your mysql work here */
>
> while ($row = mysql_fetch_array($result))
> {
> $txt .= $row['editorialname'] . "\r\n";
> /* do others */
>
> }
>
> then do your mail commands.
>
> By the way, you realize that $headers has nothing in it, yes?
>
> I'd suggest a refresher on the basics of PHP, as it looks like you're
> just copying and pasting from several sources and hoping it'll work.
> I suggest "CORE PHP Programming" as a good place to start. PHP isn't
> like HTML; you can't just steal stuff out of context and expect it to
> work.
OK. I appriciate all the help and input....this is starting to do
what I want it to do. with this code:
<?php
$today = date("M j, Y,");
echo $today;
$host="localhost";
$user="root";
$pass="";
$db="productiondb";
$con = mysql_connect($host, $user, $pass);
$txt = '';
if (!$con)
{
die('Unable to connect: ' . mysql_error());
}
mysql_select_db($db, $con) or die('Unable to connect: ' .
mysql_error());
$sql = "SELECT * FROM editorial WHERE editorialdate LIKE '$today%' ";
$result = mysql_query($sql,$con); // actually runs the query
$txt = "EDITORIAL REPORT:\n\r";
if (mysql_num_rows($result)) { // if there are results
while ($row = mysql_fetch_array($result)) { // puts the values into
$row
$txt .= $row['editorialdate'] . "\n\r";
$txt .= $row['editorialname'] . "\n\r";
$txt .= $row['editorialcomments'] . "\n\r";
}
}
//this part sends email
ini_set("SMTP", "texchange.company.com");
ini_set("smtp_port", "25");
$to = "paul@company.com";
$subject = "Production report";
$headers = "From: Daily_Prod._Report@company.com";
mail($to,$subject,$txt,$headers); # <--- sends the email
mysql_close($con); //closes the connection to the DB
?>
My email looks like this now:
EDITORIAL REPORT:
Dec 27, 2007, 1:19 pm
TEST TEST
Testing this.....
ok so If I wanted to add other data now would I just do the same thing
but maybe just use $txt2 and $txt3?
Like say I want me email to look like this:
EDITORIAL REPORT:
Dec 27, 2007, 1:19 pm editorialdate
TEST TEST editorialname
Testing this..... editorialcomments
MAIL REPORT:
Dec 27, 2007, 1:19 pm maildate
TEST TEST mailname
Testing this..... mailcomments
CIR REPORT:
Dec 27, 2007, 1:19 pm cirdate
TEST TEST cirname
Testing this..... circomments
all of these also have their own DB
so I have a DB:
editorial
mail
cir
Navigation:
[Reply to this message]
|