emailing data from my DB...??

emailing data from my DB...??

am 21.12.2007 18:56:41 von paul814

I've been working on this for some time now and have gotten
nowhere...hoping someone here can help.

I want to take and email all records in a database for the current
date when this php page is run.

Now I have a number of tables in this database...looking like this:
editorial
editorialdate, editorialname, editorialcomments
press
pressdate, pressname, presscomments
mail
maildate, mailname, mailcomments

So what I want to do is take anything for $today and put it into an
email, the email would look like this:
==
Editorial Report:
editorialdate
editorialname
editorialcomments

Mail Report:
maildate
mailname
mailcomments

etc...

here is what I have now, wich I thought would do it:

Generating and emailing report for:
$today = date("M j, Y,");
echo $today;

$host="localhost";
$user="root";
$pass="";
$db="productiondb";
$con = mysql_connect($host, $user, $pass);

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

if (mysql_num_rows($result)) { // if there are results
while ($row = mysql_fetch_array($result)) { // puts the values into
$row
print $row->editorialdate;
print $row->editorialname;
print $row->editorialcomments;
}
}

//this part sends email
ini_set("SMTP", "texchange.company.com");
ini_set("smtp_port", "25");
$to = "paul@company.com";
$subject = "Production report";
$txt = "$row[0] \n\r\n\rPLEASE DO NOT REPLY TO THIS EMAIL, THIS IS NOT
A VALID EMAIL ADDRESS";
$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 $today works fine because at the very beginning it will say:
Generating and emailing report for: Dec 21, 2007,

So I know it is getting the right date....so I am trying this for one
table in my DB now....and all I get is a blank email with no data in
it from my database.

Anyone have any ideas?

Re: emailing data from my DB...??

am 21.12.2007 19:05:50 von ivansanchez-alg

paul814@excite.com wrote:

> while ($row = mysql_fetch_array($result)) { // puts the values into
> $row
> print $row->editorialdate;
> print $row->editorialname;
> print $row->editorialcomments;
> }
[...]
> $txt = "$row[0] \n\r\n\rPLEASE DO NOT REPLY TO THIS EMAIL, THIS IS NOT
> A VALID EMAIL ADDRESS";
> $headers = "From: Daily_Prod._Report@company.com";
> mail($to,$subject,$txt,$headers); # <--- sends the email
[...]
> all I get is a blank email with no data in it from my database.
>
> Anyone have any ideas?

I'm not very sure *grin*, but maybe it's because you're printing the data
instead of storing it in the variable that will be fed to mail() ...


--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

Proudly running Debian Linux with 2.6.22-3-amd64 kernel, KDE 3.5.8, and PHP
5.2.4-2 generating this signature.
Uptime: 19:04:05 up 29 days, 5:19, 4 users, load average: 0.54, 0.63,
0.70

Re: emailing data from my DB...??

am 21.12.2007 19:15:15 von paul814

On Dec 21, 1:05 pm, Iv=E1n S=E1nchez Ortega escomposlinux.-.punto.-.org> wrote:
> paul...@excite.com wrote:
> > while ($row =3D mysql_fetch_array($result)) { // puts the values into
> > $row
> > print $row->editorialdate;
> > print $row->editorialname;
> > print $row->editorialcomments;
> > }
> [...]
> > $txt =3D "$row[0] \n\r\n\rPLEASE DO NOT REPLY TO THIS EMAIL, THIS IS NOT=

> > A VALID EMAIL ADDRESS";
> > $headers =3D "From: Daily_Prod._Rep...@company.com";
> > mail($to,$subject,$txt,$headers); # <--- sends the email
> [...]
> > all I get is a blank email with no data in it from my database.
>
> > Anyone have any ideas?
>
> I'm not very sure *grin*, but maybe it's because you're printing the data
> instead of storing it in the variable that will be fed to mail() ...
>
> --
> ----------------------------------
> Iv=E1n S=E1nchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
>
> Proudly running Debian Linux with 2.6.22-3-amd64 kernel, KDE 3.5.8, and PH=
P
> 5.2.4-2 generating this signature.
> Uptime: 19:04:05 up 29 days, 5:19, 4 users, load average: 0.54, 0.63,
> 0.70

How would I store it?

Re: emailing data from my DB...??

am 21.12.2007 19:41:13 von ivansanchez-alg

paul814@excite.com wrote:

> On Dec 21, 1:05 pm, Iván Sánchez Ortega > escomposlinux.-.punto.-.org> wrote:
>> paul...@excite.com wrote:
>> > while ($row = mysql_fetch_array($result)) { // puts the values into
>> > $row
>> > print $row->editorialdate;
>> > print $row->editorialname;
>> > print $row->editorialcomments;
>> > }
>> [...]
>> > $txt = "$row[0] \n\r\n\rPLEASE DO NOT REPLY TO THIS EMAIL, THIS IS NOT
>> > A VALID EMAIL ADDRESS";
>> > $headers = "From: Daily_Prod._Rep...@company.com";
>> > mail($to,$subject,$txt,$headers); # <--- sends the email
>> [...]
>> > all I get is a blank email with no data in it from my database.
>>
>> > Anyone have any ideas?
>>
>> I'm not very sure *grin*, but maybe it's because you're printing the data
>> instead of storing it in the variable that will be fed to mail() ...
>
> How would I store it?

Geez.

$txt = '';
while ($row = mysql_fetch_array($result)) {
$txt .= $row->editorialdate;
$txt .= $row->editorialname;
$txt .= $row->editorialcomments;
}
(snip)
mail($to,$subject,$txt,$headers);


--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

Proudly running Debian Linux with 2.6.22-3-amd64 kernel, KDE 3.5.8, and PHP
5.2.4-2 generating this signature.
Uptime: 19:39:46 up 29 days, 5:55, 4 users, load average: 0.75, 1.34,
1.05

Re: emailing data from my DB...??

am 24.12.2007 14:50:16 von paul814

On Dec 21, 1:41 pm, Iv=E1n S=E1nchez Ortega escomposlinux.-.punto.-.org> wrote:
> paul...@excite.com wrote:
> > On Dec 21, 1:05 pm, Iv=E1n S=E1nchez Ortega > > escomposlinux.-.punto.-.org> wrote:
> >> paul...@excite.com wrote:
> >> > while ($row =3D mysql_fetch_array($result)) { // puts the values in=
to
> >> > $row
> >> > print $row->editorialdate;
> >> > print $row->editorialname;
> >> > print $row->editorialcomments;
> >> > }
> >> [...]
> >> > $txt =3D "$row[0] \n\r\n\rPLEASE DO NOT REPLY TO THIS EMAIL, THIS IS =
NOT
> >> > A VALID EMAIL ADDRESS";
> >> > $headers =3D "From: Daily_Prod._Rep...@company.com";
> >> > mail($to,$subject,$txt,$headers); # <--- sends the email
> >> [...]
> >> > all I get is a blank email with no data in it from my database.
>
> >> > Anyone have any ideas?
>
> >> I'm not very sure *grin*, but maybe it's because you're printing the da=
ta
> >> instead of storing it in the variable that will be fed to mail() ...
>
> > How would I store it?
>
> Geez.
>
> $txt =3D '';
> while ($row =3D mysql_fetch_array($result)) {
> $txt .=3D $row->editorialdate;
> $txt .=3D $row->editorialname;
> $txt .=3D $row->editorialcomments;}
>
> (snip)
> mail($to,$subject,$txt,$headers);
>
> --
> ----------------------------------
> Iv=E1n S=E1nchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
>
> Proudly running Debian Linux with 2.6.22-3-amd64 kernel, KDE 3.5.8, and PH=
P
> 5.2.4-2 generating this signature.
> Uptime: 19:39:46 up 29 days, 5:55, 4 users, load average: 0.75, 1.34,
> 1.05

I still can not get this to work...I've added your changes and still
get a blank email.

Generating and emailing report for:
$today =3D date("M j, Y,");
echo $today;

$host=3D"localhost";
$user=3D"root";
$pass=3D"";
$db=3D"productiondb";
$con =3D mysql_connect($host, $user, $pass);
$txt =3D '';

if (!$con)
{
die('Unable to connect: ' . mysql_error());
}
mysql_select_db($db, $con) or die('Unable to connect: ' .
mysql_error());

$sql =3D "SELECT * FROM editorial WHERE editorialdate LIKE '$today%' ";

$result =3D mysql_query($sql,$con); // actually runs the query

if (mysql_num_rows($result)) { // if there are results
while ($row =3D mysql_fetch_array($result)) { // puts the values into
$row
$txt .=3D $row->editorialdate;
$txt .=3D $row->editorialname;
$txt .=3D $row->editorialcomments;
}
}

//this part sends email
ini_set("SMTP", "texchange.company.com");
ini_set("smtp_port", "25");
$to =3D "paul@company.com";
$subject =3D "Production report";
$txt =3D "$row \n\r\n\rPLEASE DO NOT REPLY TO THIS EMAIL, THIS IS NOT A
VALID EMAIL ADDRESS";
$headers =3D "From: Daily_Prod._Report@company.com";
mail($to,$subject,$txt,$headers); # <--- sends the email

mysql_close($con); //closes the connection to the DB

?>

Any ideas? thanks.

Re: emailing data from my DB...??

am 24.12.2007 15:32:27 von My Pet Programmer

paul814@excite.com said:
> On Dec 21, 1:41 pm, Iv=E1n S=E1nchez Ortega > escomposlinux.-.punto.-.org> wrote:
>> paul...@excite.com wrote:
>>> On Dec 21, 1:05 pm, Iv=E1n S=E1nchez Ortega >>> escomposlinux.-.punto.-.org> wrote:
>>>> paul...@excite.com wrote:
>>>>> while ($row =3D mysql_fetch_array($result)) { // puts the values =
into
>>>>> $row
>>>>> print $row->editorialdate;
>>>>> print $row->editorialname;
>>>>> print $row->editorialcomments;
>>>>> }
>>>> [...]
>>>>> $txt =3D "$row[0] \n\r\n\rPLEASE DO NOT REPLY TO THIS EMAIL, THIS I=
S NOT
>>>>> A VALID EMAIL ADDRESS";
>>>>> $headers =3D "From: Daily_Prod._Rep...@company.com";
>>>>> mail($to,$subject,$txt,$headers); # <--- sends the email
>>>> [...]
>>>>> all I get is a blank email with no data in it from my database.
>>>>> Anyone have any ideas?
>>>> I'm not very sure *grin*, but maybe it's because you're printing the=
data
>>>> instead of storing it in the variable that will be fed to mail() ...=

>>> How would I store it?
>> Geez.
>>
>> $txt =3D '';
>> while ($row =3D mysql_fetch_array($result)) {
>> $txt .=3D $row->editorialdate;
>> $txt .=3D $row->editorialname;
>> $txt .=3D $row->editorialcomments;}
>>
>> (snip)
>> mail($to,$subject,$txt,$headers);
>>
>> --
>> ----------------------------------
>> Iv=E1n S=E1nchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org=
-
>>
>> Proudly running Debian Linux with 2.6.22-3-amd64 kernel, KDE 3.5.8, an=
d PHP
>> 5.2.4-2 generating this signature.
>> Uptime: 19:39:46 up 29 days, 5:55, 4 users, load average: 0.75, 1.3=
4,
>> 1.05
>=20
> I still can not get this to work...I've added your changes and still
> get a blank email.
>=20
> Generating and emailing report for:
> > $today =3D date("M j, Y,");
> echo $today;
>=20
> $host=3D"localhost";
> $user=3D"root";
> $pass=3D"";
> $db=3D"productiondb";
> $con =3D mysql_connect($host, $user, $pass);
> $txt =3D '';
>=20
> if (!$con)
> {
> die('Unable to connect: ' . mysql_error());
> }
> mysql_select_db($db, $con) or die('Unable to connect: ' .
> mysql_error());
>=20
> $sql =3D "SELECT * FROM editorial WHERE editorialdate LIKE '$today%' ";=

>=20
> $result =3D mysql_query($sql,$con); // actually runs the query
>=20
> if (mysql_num_rows($result)) { // if there are results
> while ($row =3D mysql_fetch_array($result)) { // puts the values into=

> $row
> $txt .=3D $row->editorialdate;
> $txt .=3D $row->editorialname;
> $txt .=3D $row->editorialcomments;
> }
> }
>=20
> //this part sends email
> ini_set("SMTP", "texchange.company.com");
> ini_set("smtp_port", "25");
> $to =3D "paul@company.com";
> $subject =3D "Production report";
> $txt =3D "$row \n\r\n\rPLEASE DO NOT REPLY TO THIS EMAIL, THIS IS NOT A=

> VALID EMAIL ADDRESS";
> $headers =3D "From: Daily_Prod._Report@company.com";
> mail($to,$subject,$txt,$headers); # <--- sends the email
>=20
> mysql_close($con); //closes the connection to the DB
>=20
> ?>
>=20
> Any ideas? thanks.

I might be wrong, but don't the headers require a newline at the end?=20
That might have something to do with it, but I don't see anything else.

~A!

Re: emailing data from my DB...??

am 24.12.2007 16:18:20 von paul814

On Dec 24, 9:32 am, My Pet Programmer
wrote:
> paul...@excite.com said:
>
>
>
> > On Dec 21, 1:41 pm, Iv=E1n S=E1nchez Ortega > > escomposlinux.-.punto.-.org> wrote:
> >> paul...@excite.com wrote:
> >>> On Dec 21, 1:05 pm, Iv=E1n S=E1nchez Ortega > >>> escomposlinux.-.punto.-.org> wrote:
> >>>> paul...@excite.com wrote:
> >>>>> while ($row =3D mysql_fetch_array($result)) { // puts the values i=
nto
> >>>>> $row
> >>>>> print $row->editorialdate;
> >>>>> print $row->editorialname;
> >>>>> print $row->editorialcomments;
> >>>>> }
> >>>> [...]
> >>>>> $txt =3D "$row[0] \n\r\n\rPLEASE DO NOT REPLY TO THIS EMAIL, THIS IS=
NOT
> >>>>> A VALID EMAIL ADDRESS";
> >>>>> $headers =3D "From: Daily_Prod._Rep...@company.com";
> >>>>> mail($to,$subject,$txt,$headers); # <--- sends the email
> >>>> [...]
> >>>>> all I get is a blank email with no data in it from my database.
> >>>>> Anyone have any ideas?
> >>>> I'm not very sure *grin*, but maybe it's because you're printing the =
data
> >>>> instead of storing it in the variable that will be fed to mail() ...
> >>> How would I store it?
> >> Geez.
>
> >> $txt =3D '';
> >> while ($row =3D mysql_fetch_array($result)) {
> >> $txt .=3D $row->editorialdate;
> >> $txt .=3D $row->editorialname;
> >> $txt .=3D $row->editorialcomments;}
>
> >> (snip)
> >> mail($to,$subject,$txt,$headers);
>
> >> --
> >> ----------------------------------
> >> Iv=E1n S=E1nchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-=

>
> >> Proudly running Debian Linux with 2.6.22-3-amd64 kernel, KDE 3.5.8, and=
PHP
> >> 5.2.4-2 generating this signature.
> >> Uptime: 19:39:46 up 29 days, 5:55, 4 users, load average: 0.75, 1.34=
,
> >> 1.05
>
> > I still can not get this to work...I've added your changes and still
> > get a blank email.
>
> > Generating and emailing report for:
> > > > $today =3D date("M j, Y,");
> > echo $today;
>
> > $host=3D"localhost";
> > $user=3D"root";
> > $pass=3D"";
> > $db=3D"productiondb";
> > $con =3D mysql_connect($host, $user, $pass);
> > $txt =3D '';
>
> > if (!$con)
> > {
> > die('Unable to connect: ' . mysql_error());
> > }
> > mysql_select_db($db, $con) or die('Unable to connect: ' .
> > mysql_error());
>
> > $sql =3D "SELECT * FROM editorial WHERE editorialdate LIKE '$today%' ";
>
> > $result =3D mysql_query($sql,$con); // actually runs the query
>
> > if (mysql_num_rows($result)) { // if there are results
> > while ($row =3D mysql_fetch_array($result)) { // puts the values into
> > $row
> > $txt .=3D $row->editorialdate;
> > $txt .=3D $row->editorialname;
> > $txt .=3D $row->editorialcomments;
> > }
> > }
>
> > //this part sends email
> > ini_set("SMTP", "texchange.company.com");
> > ini_set("smtp_port", "25");
> > $to =3D "p...@company.com";
> > $subject =3D "Production report";
> > $txt =3D "$row \n\r\n\rPLEASE DO NOT REPLY TO THIS EMAIL, THIS IS NOT A
> > VALID EMAIL ADDRESS";
> > $headers =3D "From: Daily_Prod._Rep...@company.com";
> > mail($to,$subject,$txt,$headers); # <--- sends the email
>
> > mysql_close($con); //closes the connection to the DB
>
> > ?>
>
> > Any ideas? thanks.
>
> I might be wrong, but don't the headers require a newline at the end?
> That might have something to do with it, but I don't see anything else.
>
> ~A!

Well I tried that and that did not change anything

Re: emailing data from my DB...??

am 24.12.2007 16:22:54 von My Pet Programmer

paul814@excite.com said:
> On Dec 24, 9:32 am, My Pet Programmer
> wrote:
>> paul...@excite.com said:
>>
>>
>>
>>> On Dec 21, 1:41 pm, Iv=E1n S=E1nchez Ortega >>> escomposlinux.-.punto.-.org> wrote:
>>>> paul...@excite.com wrote:
>>>>> On Dec 21, 1:05 pm, Iv=E1n S=E1nchez Ortega
>>>>> escomposlinux.-.punto.-.org> wrote:
>>>>>> paul...@excite.com wrote:
>>>>>>> while ($row =3D mysql_fetch_array($result)) { // puts the value=
s into
>>>>>>> $row
>>>>>>> print $row->editorialdate;
>>>>>>> print $row->editorialname;
>>>>>>> print $row->editorialcomments;
>>>>>>> }
>>>>>> [...]
>>>>>>> $txt =3D "$row[0] \n\r\n\rPLEASE DO NOT REPLY TO THIS EMAIL, THIS=
IS NOT
>>>>>>> A VALID EMAIL ADDRESS";
>>>>>>> $headers =3D "From: Daily_Prod._Rep...@company.com";
>>>>>>> mail($to,$subject,$txt,$headers); # <--- sends the email
>>>>>> [...]
>>>>>>> all I get is a blank email with no data in it from my database.
>>>>>>> Anyone have any ideas?
>>>>>> I'm not very sure *grin*, but maybe it's because you're printing t=
he data
>>>>>> instead of storing it in the variable that will be fed to mail() .=
.
>>>>> How would I store it?
>>>> Geez.
>>>> $txt =3D '';
>>>> while ($row =3D mysql_fetch_array($result)) {
>>>> $txt .=3D $row->editorialdate;
>>>> $txt .=3D $row->editorialname;
>>>> $txt .=3D $row->editorialcomments;}
>>>> (snip)
>>>> mail($to,$subject,$txt,$headers);
>>>> --
>>>> ----------------------------------
>>>> Iv=E1n S=E1nchez Ortega -ivansanchez-algarroba-escomposlinux-punto-o=
rg-
>>>> Proudly running Debian Linux with 2.6.22-3-amd64 kernel, KDE 3.5.8, =
and PHP
>>>> 5.2.4-2 generating this signature.
>>>> Uptime: 19:39:46 up 29 days, 5:55, 4 users, load average: 0.75, 1=
34,
>>>> 1.05
>>> I still can not get this to work...I've added your changes and still
>>> get a blank email.
>>> Generating and emailing report for:
>>> >>> $today =3D date("M j, Y,");
>>> echo $today;
>>> $host=3D"localhost";
>>> $user=3D"root";
>>> $pass=3D"";
>>> $db=3D"productiondb";
>>> $con =3D mysql_connect($host, $user, $pass);
>>> $txt =3D '';
>>> if (!$con)
>>> {
>>> die('Unable to connect: ' . mysql_error());
>>> }
>>> mysql_select_db($db, $con) or die('Unable to connect: ' .
>>> mysql_error());
>>> $sql =3D "SELECT * FROM editorial WHERE editorialdate LIKE '$today%' =
";
>>> $result =3D mysql_query($sql,$con); // actually runs the query
>>> if (mysql_num_rows($result)) { // if there are results
>>> while ($row =3D mysql_fetch_array($result)) { // puts the values in=
to
>>> $row
>>> $txt .=3D $row->editorialdate;
>>> $txt .=3D $row->editorialname;
>>> $txt .=3D $row->editorialcomments;
>>> }
>>> }
>>> //this part sends email
>>> ini_set("SMTP", "texchange.company.com");
>>> ini_set("smtp_port", "25");
>>> $to =3D "p...@company.com";
>>> $subject =3D "Production report";
>>> $txt =3D "$row \n\r\n\rPLEASE DO NOT REPLY TO THIS EMAIL, THIS IS NOT=
A
>>> VALID EMAIL ADDRESS";
>>> $headers =3D "From: Daily_Prod._Rep...@company.com";
>>> mail($to,$subject,$txt,$headers); # <--- sends the email
>>> mysql_close($con); //closes the connection to the DB
>>> ?>
>>> Any ideas? thanks.
>> I might be wrong, but don't the headers require a newline at the end?
>> That might have something to do with it, but I don't see anything else=

>>
>> ~A!
>=20
> Well I tried that and that did not change anything

What do you get if you print $txt and exit? Is that populated ok?

Re: emailing data from my DB...??

am 24.12.2007 16:33:02 von paul814

On Dec 24, 10:22 am, My Pet Programmer
wrote:
> paul...@excite.com said:
>
>
>
> > On Dec 24, 9:32 am, My Pet Programmer
> > wrote:
> >> paul...@excite.com said:
>
> >>> On Dec 21, 1:41 pm, Iv=E1n S=E1nchez Ortega > >>> escomposlinux.-.punto.-.org> wrote:
> >>>> paul...@excite.com wrote:
> >>>>> On Dec 21, 1:05 pm, Iv=E1n S=E1nchez Ortega > >>>>> escomposlinux.-.punto.-.org> wrote:
> >>>>>> paul...@excite.com wrote:
> >>>>>>> while ($row =3D mysql_fetch_array($result)) { // puts the values=
into
> >>>>>>> $row
> >>>>>>> print $row->editorialdate;
> >>>>>>> print $row->editorialname;
> >>>>>>> print $row->editorialcomments;
> >>>>>>> }
> >>>>>> [...]
> >>>>>>> $txt =3D "$row[0] \n\r\n\rPLEASE DO NOT REPLY TO THIS EMAIL, THIS =
IS NOT
> >>>>>>> A VALID EMAIL ADDRESS";
> >>>>>>> $headers =3D "From: Daily_Prod._Rep...@company.com";
> >>>>>>> mail($to,$subject,$txt,$headers); # <--- sends the email
> >>>>>> [...]
> >>>>>>> all I get is a blank email with no data in it from my database.
> >>>>>>> Anyone have any ideas?
> >>>>>> I'm not very sure *grin*, but maybe it's because you're printing th=
e data
> >>>>>> instead of storing it in the variable that will be fed to mail() ..=
..
> >>>>> How would I store it?
> >>>> Geez.
> >>>> $txt =3D '';
> >>>> while ($row =3D mysql_fetch_array($result)) {
> >>>> $txt .=3D $row->editorialdate;
> >>>> $txt .=3D $row->editorialname;
> >>>> $txt .=3D $row->editorialcomments;}
> >>>> (snip)
> >>>> mail($to,$subject,$txt,$headers);
> >>>> --
> >>>> ----------------------------------
> >>>> Iv=E1n S=E1nchez Ortega -ivansanchez-algarroba-escomposlinux-punto-or=
g-
> >>>> Proudly running Debian Linux with 2.6.22-3-amd64 kernel, KDE 3.5.8, a=
nd PHP
> >>>> 5.2.4-2 generating this signature.
> >>>> Uptime: 19:39:46 up 29 days, 5:55, 4 users, load average: 0.75, 1.=
34,
> >>>> 1.05
> >>> I still can not get this to work...I've added your changes and still
> >>> get a blank email.
> >>> Generating and emailing report for:
> >>> > >>> $today =3D date("M j, Y,");
> >>> echo $today;
> >>> $host=3D"localhost";
> >>> $user=3D"root";
> >>> $pass=3D"";
> >>> $db=3D"productiondb";
> >>> $con =3D mysql_connect($host, $user, $pass);
> >>> $txt =3D '';
> >>> if (!$con)
> >>> {
> >>> die('Unable to connect: ' . mysql_error());
> >>> }
> >>> mysql_select_db($db, $con) or die('Unable to connect: ' .
> >>> mysql_error());
> >>> $sql =3D "SELECT * FROM editorial WHERE editorialdate LIKE '$today%' "=
;
> >>> $result =3D mysql_query($sql,$con); // actually runs the query
> >>> if (mysql_num_rows($result)) { // if there are results
> >>> while ($row =3D mysql_fetch_array($result)) { // puts the values int=
o
> >>> $row
> >>> $txt .=3D $row->editorialdate;
> >>> $txt .=3D $row->editorialname;
> >>> $txt .=3D $row->editorialcomments;
> >>> }
> >>> }
> >>> //this part sends email
> >>> ini_set("SMTP", "texchange.company.com");
> >>> ini_set("smtp_port", "25");
> >>> $to =3D "p...@company.com";
> >>> $subject =3D "Production report";
> >>> $txt =3D "$row \n\r\n\rPLEASE DO NOT REPLY TO THIS EMAIL, THIS IS NOT =
A
> >>> VALID EMAIL ADDRESS";
> >>> $headers =3D "From: Daily_Prod._Rep...@company.com";
> >>> mail($to,$subject,$txt,$headers); # <--- sends the email
> >>> mysql_close($con); //closes the connection to the DB
> >>> ?>
> >>> Any ideas? thanks.
> >> I might be wrong, but don't the headers require a newline at the end?
> >> That might have something to do with it, but I don't see anything else.=

>
> >> ~A!
>
> > Well I tried that and that did not change anything
>
> What do you get if you print $txt and exit? Is that populated ok?

If I echo $txt on the page....I get:
PLEASE DO NOT REPLY TO THIS EMAIL, THIS IS NOT A VALID EMAIL ADDRESS

Re: emailing data from my DB...??

am 24.12.2007 16:36:42 von My Pet Programmer

paul814@excite.com said:
> On Dec 24, 10:22 am, My Pet Programmer
> wrote:
>> paul...@excite.com said:
>>
>>
>>
>>> On Dec 24, 9:32 am, My Pet Programmer
>>> wrote:
>>>> paul...@excite.com said:
>>>>> On Dec 21, 1:41 pm, Iv=E1n S=E1nchez Ortega
>>>>> escomposlinux.-.punto.-.org> wrote:
>>>>>> paul...@excite.com wrote:
>>>>>>> On Dec 21, 1:05 pm, Iv=E1n S=E1nchez Ortega a-
>>>>>>> escomposlinux.-.punto.-.org> wrote:
>>>>>>>> paul...@excite.com wrote:
>>>>>>>>> while ($row =3D mysql_fetch_array($result)) { // puts the val=
ues into
>>>>>>>>> $row
>>>>>>>>> print $row->editorialdate;
>>>>>>>>> print $row->editorialname;
>>>>>>>>> print $row->editorialcomments;
>>>>>>>>> }
>>>>>>>> [...]
>>>>>>>>> $txt =3D "$row[0] \n\r\n\rPLEASE DO NOT REPLY TO THIS EMAIL, TH=
IS IS NOT
>>>>>>>>> A VALID EMAIL ADDRESS";
>>>>>>>>> $headers =3D "From: Daily_Prod._Rep...@company.com";
>>>>>>>>> mail($to,$subject,$txt,$headers); # <--- sends the email
>>>>>>>> [...]
>>>>>>>>> all I get is a blank email with no data in it from my database.=

>>>>>>>>> Anyone have any ideas?
>>>>>>>> I'm not very sure *grin*, but maybe it's because you're printing=
the data
>>>>>>>> instead of storing it in the variable that will be fed to mail()=
...
>>>>>>> How would I store it?
>>>>>> Geez.
>>>>>> $txt =3D '';
>>>>>> while ($row =3D mysql_fetch_array($result)) {
>>>>>> $txt .=3D $row->editorialdate;
>>>>>> $txt .=3D $row->editorialname;
>>>>>> $txt .=3D $row->editorialcomments;}
>>>>>> (snip)
>>>>>> mail($to,$subject,$txt,$headers);
>>>>>> --
>>>>>> ----------------------------------
>>>>>> Iv=E1n S=E1nchez Ortega -ivansanchez-algarroba-escomposlinux-punto=
-org-
>>>>>> Proudly running Debian Linux with 2.6.22-3-amd64 kernel, KDE 3.5.8=
, and PHP
>>>>>> 5.2.4-2 generating this signature.
>>>>>> Uptime: 19:39:46 up 29 days, 5:55, 4 users, load average: 0.75,=
1.34,
>>>>>> 1.05
>>>>> I still can not get this to work...I've added your changes and stil=
l
>>>>> get a blank email.
>>>>> Generating and emailing report for:
>>>>> >>>>> $today =3D date("M j, Y,");
>>>>> echo $today;
>>>>> $host=3D"localhost";
>>>>> $user=3D"root";
>>>>> $pass=3D"";
>>>>> $db=3D"productiondb";
>>>>> $con =3D mysql_connect($host, $user, $pass);
>>>>> $txt =3D '';
>>>>> if (!$con)
>>>>> {
>>>>> die('Unable to connect: ' . mysql_error());
>>>>> }
>>>>> mysql_select_db($db, $con) or die('Unable to connect: ' .
>>>>> mysql_error());
>>>>> $sql =3D "SELECT * FROM editorial WHERE editorialdate LIKE '$today%=
' ";
>>>>> $result =3D mysql_query($sql,$con); // actually runs the query
>>>>> if (mysql_num_rows($result)) { // if there are results
>>>>> while ($row =3D mysql_fetch_array($result)) { // puts the values =
into
>>>>> $row
>>>>> $txt .=3D $row->editorialdate;
>>>>> $txt .=3D $row->editorialname;
>>>>> $txt .=3D $row->editorialcomments;
>>>>> }
>>>>> }
>>>>> //this part sends email
>>>>> ini_set("SMTP", "texchange.company.com");
>>>>> ini_set("smtp_port", "25");
>>>>> $to =3D "p...@company.com";
>>>>> $subject =3D "Production report";
>>>>> $txt =3D "$row \n\r\n\rPLEASE DO NOT REPLY TO THIS EMAIL, THIS IS N=
OT A
>>>>> VALID EMAIL ADDRESS";
>>>>> $headers =3D "From: Daily_Prod._Rep...@company.com";
>>>>> mail($to,$subject,$txt,$headers); # <--- sends the email
>>>>> mysql_close($con); //closes the connection to the DB
>>>>> ?>
>>>>> Any ideas? thanks.
>>>> I might be wrong, but don't the headers require a newline at the end=
?
>>>> That might have something to do with it, but I don't see anything el=
se.
>>>> ~A!
>>> Well I tried that and that did not change anything
>> What do you get if you print $txt and exit? Is that populated ok?
>=20
> If I echo $txt on the page....I get:
> PLEASE DO NOT REPLY TO THIS EMAIL, THIS IS NOT A VALID EMAIL ADDRESS

Just out of curiosity, what is the column def on the date field in the=20
table? The usual format for date queries from MySQL is Y-m-d for DATE=20
and Y-m-d g:i:s for date time. It looks like $txt is not getting=20
populated at all, and I'm thinking it's maybe not getting anything from=20
the recordset.

~A!

Re: emailing data from my DB...??

am 24.12.2007 16:53:55 von paul814

On Dec 24, 10:36 am, My Pet Programmer
wrote:
> paul...@excite.com said:
>
>
>
> > On Dec 24, 10:22 am, My Pet Programmer
> > wrote:
> >> paul...@excite.com said:
>
> >>> On Dec 24, 9:32 am, My Pet Programmer
> >>> wrote:
> >>>> paul...@excite.com said:
> >>>>> On Dec 21, 1:41 pm, Iv=E1n S=E1nchez Ortega > >>>>> escomposlinux.-.punto.-.org> wrote:
> >>>>>> paul...@excite.com wrote:
> >>>>>>> On Dec 21, 1:05 pm, Iv=E1n S=E1nchez Ortega -
> >>>>>>> escomposlinux.-.punto.-.org> wrote:
> >>>>>>>> paul...@excite.com wrote:
> >>>>>>>>> while ($row =3D mysql_fetch_array($result)) { // puts the valu=
es into
> >>>>>>>>> $row
> >>>>>>>>> print $row->editorialdate;
> >>>>>>>>> print $row->editorialname;
> >>>>>>>>> print $row->editorialcomments;
> >>>>>>>>> }
> >>>>>>>> [...]
> >>>>>>>>> $txt =3D "$row[0] \n\r\n\rPLEASE DO NOT REPLY TO THIS EMAIL, THI=
S IS NOT
> >>>>>>>>> A VALID EMAIL ADDRESS";
> >>>>>>>>> $headers =3D "From: Daily_Prod._Rep...@company.com";
> >>>>>>>>> mail($to,$subject,$txt,$headers); # <--- sends the email
> >>>>>>>> [...]
> >>>>>>>>> all I get is a blank email with no data in it from my database.
> >>>>>>>>> Anyone have any ideas?
> >>>>>>>> I'm not very sure *grin*, but maybe it's because you're printing =
the data
> >>>>>>>> instead of storing it in the variable that will be fed to mail() =
....
> >>>>>>> How would I store it?
> >>>>>> Geez.
> >>>>>> $txt =3D '';
> >>>>>> while ($row =3D mysql_fetch_array($result)) {
> >>>>>> $txt .=3D $row->editorialdate;
> >>>>>> $txt .=3D $row->editorialname;
> >>>>>> $txt .=3D $row->editorialcomments;}
> >>>>>> (snip)
> >>>>>> mail($to,$subject,$txt,$headers);
> >>>>>> --
> >>>>>> ----------------------------------
> >>>>>> Iv=E1n S=E1nchez Ortega -ivansanchez-algarroba-escomposlinux-punto-=
org-
> >>>>>> Proudly running Debian Linux with 2.6.22-3-amd64 kernel, KDE 3.5.8,=
and PHP
> >>>>>> 5.2.4-2 generating this signature.
> >>>>>> Uptime: 19:39:46 up 29 days, 5:55, 4 users, load average: 0.75, =
1.34,
> >>>>>> 1.05
> >>>>> I still can not get this to work...I've added your changes and still=

> >>>>> get a blank email.
> >>>>> Generating and emailing report for:
> >>>>> > >>>>> $today =3D date("M j, Y,");
> >>>>> echo $today;
> >>>>> $host=3D"localhost";
> >>>>> $user=3D"root";
> >>>>> $pass=3D"";
> >>>>> $db=3D"productiondb";
> >>>>> $con =3D mysql_connect($host, $user, $pass);
> >>>>> $txt =3D '';
> >>>>> if (!$con)
> >>>>> {
> >>>>> die('Unable to connect: ' . mysql_error());
> >>>>> }
> >>>>> mysql_select_db($db, $con) or die('Unable to connect: ' .
> >>>>> mysql_error());
> >>>>> $sql =3D "SELECT * FROM editorial WHERE editorialdate LIKE '$today%'=
";
> >>>>> $result =3D mysql_query($sql,$con); // actually runs the query
> >>>>> if (mysql_num_rows($result)) { // if there are results
> >>>>> while ($row =3D mysql_fetch_array($result)) { // puts the values i=
nto
> >>>>> $row
> >>>>> $txt .=3D $row->editorialdate;
> >>>>> $txt .=3D $row->editorialname;
> >>>>> $txt .=3D $row->editorialcomments;
> >>>>> }
> >>>>> }
> >>>>> //this part sends email
> >>>>> ini_set("SMTP", "texchange.company.com");
> >>>>> ini_set("smtp_port", "25");
> >>>>> $to =3D "p...@company.com";
> >>>>> $subject =3D "Production report";
> >>>>> $txt =3D "$row \n\r\n\rPLEASE DO NOT REPLY TO THIS EMAIL, THIS IS NO=
T A
> >>>>> VALID EMAIL ADDRESS";
> >>>>> $headers =3D "From: Daily_Prod._Rep...@company.com";
> >>>>> mail($to,$subject,$txt,$headers); # <--- sends the email
> >>>>> mysql_close($con); //closes the connection to the DB
> >>>>> ?>
> >>>>> Any ideas? thanks.
> >>>> I might be wrong, but don't the headers require a newline at the end?=

> >>>> That might have something to do with it, but I don't see anything els=
e.
> >>>> ~A!
> >>> Well I tried that and that did not change anything
> >> What do you get if you print $txt and exit? Is that populated ok?
>
> > If I echo $txt on the page....I get:
> > PLEASE DO NOT REPLY TO THIS EMAIL, THIS IS NOT A VALID EMAIL ADDRESS
>
> Just out of curiosity, what is the column def on the date field in the
> table? The usual format for date queries from MySQL is Y-m-d for DATE
> and Y-m-d g:i:s for date time. It looks like $txt is not getting
> populated at all, and I'm thinking it's maybe not getting anything from
> the recordset.
>
> ~A!

Well the editorialdate is stored as a VARCHAR and I have to do it that
way because of some other things that I am doing...I cant store it as
DATE/TIME. But it is populated as:
Dec 24, 2007, 8:37 am
for example.

Re: emailing data from my DB...??

am 24.12.2007 16:59:01 von My Pet Programmer

paul814@excite.com said:

> Well the editorialdate is stored as a VARCHAR and I have to do it that
> way because of some other things that I am doing...I cant store it as
> DATE/TIME. But it is populated as:
> Dec 24, 2007, 8:37 am
> for example.

Ouch, sorry to hear that. Have you traced back to see what you're
getting from the DB? Just a print_r on the rows would do ya. That way
you can narrow down where the problem is. If it's just the query, that's
pretty simple to resolve in most cases.

~A!

Re: emailing data from my DB...??

am 24.12.2007 17:23:42 von paul814

On Dec 24, 10:59 am, My Pet Programmer
wrote:
> paul...@excite.com said:
>
> > Well the editorialdate is stored as a VARCHAR and I have to do it that
> > way because of some other things that I am doing...I cant store it as
> > DATE/TIME. But it is populated as:
> > Dec 24, 2007, 8:37 am
> > for example.
>
> Ouch, sorry to hear that. Have you traced back to see what you're
> getting from the DB? Just a print_r on the rows would do ya. That way
> you can narrow down where the problem is. If it's just the query, that's
> pretty simple to resolve in most cases.
>
> ~A!

I dont know how to do the print_r but this is what one of my
editorialdate fields looks like...its a copy and paste right from the
DB:
Dec 24, 2007, 8:37 am
that is exactly what it looks like in the DB.
but in my page I am only looking for the first characters of the
date....so my query is anyhting that looks like this:
Dec 24, 2007,
I don't care about the time at all just the date, that is why I am
doing this:

$today = date("M j, Y,");
echo $today; (this displays like: Dec 24, 2007,)

and then that is why my query looks like this:
$sql = "SELECT * FROM editorial WHERE editorialdate LIKE '$today%' ";

So basically select everything from editorial where the editorialdate
field is like Dec 24, 2007,

Re: emailing data from my DB...??

am 24.12.2007 17:29:57 von My Pet Programmer

paul814@excite.com said:
[snip]
>
> $today = date("M j, Y,");
> echo $today; (this displays like: Dec 24, 2007,)
>
> and then that is why my query looks like this:
> $sql = "SELECT * FROM editorial WHERE editorialdate LIKE '$today%' ";
>
> So basically select everything from editorial where the editorialdate
> field is like Dec 24, 2007,

Oh, no, don't get me wrong, I know what you're doing in the code, I'm
just curious what you're actually getting for records in the page. When
you print $txt and nothing comes out, I start to think things aren't
coming out of the DB. Try just echoing the mysql_num_rows call to the
page, see what you come up with.

print_r is a variable dumper, and the syntax is:
print_r($variable);

Doing that extracts all the info about a variable and prints to the
screen for you.

~A!

Re: emailing data from my DB...??

am 24.12.2007 18:40:47 von ivansanchez-alg

paul814@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%)

Re: emailing data from my DB...??

am 24.12.2007 19:06:51 von paul814

On Dec 24, 12:40 pm, Iv=E1n S=E1nchez Ortega 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=E1n S=E1nchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
>
> Now listening to: Sigur R=F3s - Takk... (2005) - [5] S=E9 Lest (8:40)
> (96.000000%)

So what do I need to do to put editorialdate, editorialname, and
editorialcomments in an email?

Re: emailing data from my DB...??

am 25.12.2007 10:59:40 von aeg

On Dec 21, 5:56 pm, paul...@excite.com wrote:
> print $row->editorialdate;
> print $row->editorialname;
> print $row->editorialcomments;

You should be doing $row['editorialdate'] to read from the array not
the way you're doing it which is attempted to read from a class (which
you haven't got).

Surely? Unless I'm missing something?

Re: emailing data from my DB...??

am 26.12.2007 15:10:43 von zburnham

On Dec 24, 1:06 pm, paul...@excite.com wrote:
> On Dec 24, 12:40 pm, Iv=E1n S=E1nchez Ortega >
>
>
> 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=E1n S=E1nchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
>
> > Now listening to: Sigur R=F3s - Takk... (2005) - [5] S=E9 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 =3D "PLEASE DO NOT REPLY TO THIS EMAIL, THIS IS NOT A
VALID EMAIL ADDRESS";

/* do your mysql work here */

while ($row =3D mysql_fetch_array($result))
{
$txt .=3D $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.

Re: emailing data from my DB...??

am 27.12.2007 19:35:36 von paul814

On Dec 26, 9:10 am, Evil Otto wrote:
> On Dec 24, 1:06 pm, paul...@excite.com wrote:
>
>
>
> > On Dec 24, 12:40 pm, Iv=E1n S=E1nchez Ortega >
> > 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=E1n S=E1nchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org=
-
>
> > > Now listening to: Sigur R=F3s - Takk... (2005) - [5] S=E9 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 =3D "PLEASE DO NOT REPLY TO THIS EMAIL, THIS IS NOT A
> VALID EMAIL ADDRESS";
>
> /* do your mysql work here */
>
> while ($row =3D mysql_fetch_array($result))
> {
> $txt .=3D $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:
$today =3D date("M j, Y,");
echo $today;

$host=3D"localhost";
$user=3D"root";
$pass=3D"";
$db=3D"productiondb";
$con =3D mysql_connect($host, $user, $pass);
$txt =3D '';

if (!$con)
{
die('Unable to connect: ' . mysql_error());
}
mysql_select_db($db, $con) or die('Unable to connect: ' .
mysql_error());

$sql =3D "SELECT * FROM editorial WHERE editorialdate LIKE '$today%' ";

$result =3D mysql_query($sql,$con); // actually runs the query
$txt =3D "EDITORIAL REPORT:\n\r";

if (mysql_num_rows($result)) { // if there are results
while ($row =3D mysql_fetch_array($result)) { // puts the values into
$row
$txt .=3D $row['editorialdate'] . "\n\r";
$txt .=3D $row['editorialname'] . "\n\r";
$txt .=3D $row['editorialcomments'] . "\n\r";
}
}

//this part sends email
ini_set("SMTP", "texchange.company.com");
ini_set("smtp_port", "25");
$to =3D "paul@company.com";
$subject =3D "Production report";
$headers =3D "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

Re: emailing data from my DB...??

am 28.12.2007 12:05:39 von jpyers

On Dec 24, 5:50 am, paul...@excite.com wrote:
> On Dec 21, 1:41 pm, Iv=E1n S=E1nchez Ortega >
>
>
> escomposlinux.-.punto.-.org> wrote:
> > paul...@excite.com wrote:
> > > On Dec 21, 1:05 pm, Iv=E1n S=E1nchez Ortega > > > escomposlinux.-.punto.-.org> wrote:
> > >> paul...@excite.com wrote:
> > >> > while ($row =3D mysql_fetch_array($result)) { // puts the values =
into
> > >> > $row
> > >> > print $row->editorialdate;
> > >> > print $row->editorialname;
> > >> > print $row->editorialcomments;
> > >> > }
> > >> [...]
> > >> > $txt =3D "$row[0] \n\r\n\rPLEASE DO NOT REPLY TO THIS EMAIL, THIS I=
S NOT
> > >> > A VALID EMAIL ADDRESS";
> > >> > $headers =3D "From: Daily_Prod._Rep...@company.com";
> > >> > mail($to,$subject,$txt,$headers); # <--- sends the email
> > >> [...]
> > >> > all I get is a blank email with no data in it from my database.
>
> > >> > Anyone have any ideas?
>
> > >> I'm not very sure *grin*, but maybe it's because you're printing the =
data
> > >> instead of storing it in the variable that will be fed to mail() ...
>
> > > How would I store it?
>
> > Geez.
>
> > $txt =3D '';
> > while ($row =3D mysql_fetch_array($result)) {
> > $txt .=3D $row->editorialdate;
> > $txt .=3D $row->editorialname;
> > $txt .=3D $row->editorialcomments;}
>
> > (snip)
> > mail($to,$subject,$txt,$headers);
>
> > --
> > ----------------------------------
> > Iv=E1n S=E1nchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
>
> > Proudly running Debian Linux with 2.6.22-3-amd64 kernel, KDE 3.5.8, and =
PHP
> > 5.2.4-2 generating this signature.
> > Uptime: 19:39:46 up 29 days, 5:55, 4 users, load average: 0.75, 1.34,=

> > 1.05
>
> I still can not get this to work...I've added your changes and still
> get a blank email.
>
> Generating and emailing report for:
> > $today =3D date("M j, Y,");
> echo $today;
>
> $host=3D"localhost";
> $user=3D"root";
> $pass=3D"";
> $db=3D"productiondb";
> $con =3D mysql_connect($host, $user, $pass);
> $txt =3D '';
>
> if (!$con)
> {
> die('Unable to connect: ' . mysql_error());
> }
> mysql_select_db($db, $con) or die('Unable to connect: ' .
> mysql_error());
>
> $sql =3D "SELECT * FROM editorial WHERE editorialdate LIKE '$today%' ";
>
> $result =3D mysql_query($sql,$con); // actually runs the query
>
> if (mysql_num_rows($result)) { // if there are results
> while ($row =3D mysql_fetch_array($result)) { // puts the values into
> $row
> $txt .=3D $row->editorialdate;
> $txt .=3D $row->editorialname;
> $txt .=3D $row->editorialcomments;
> }
>
> }
>
> //this part sends email
> ini_set("SMTP", "texchange.company.com");
> ini_set("smtp_port", "25");
> $to =3D "p...@company.com";
> $subject =3D "Production report";
> $txt =3D "$row \n\r\n\rPLEASE DO NOT REPLY TO THIS EMAIL, THIS IS NOT A
> VALID EMAIL ADDRESS";
> $headers =3D "From: Daily_Prod._Rep...@company.com";
> mail($to,$subject,$txt,$headers); # <--- sends the email
>
> mysql_close($con); //closes the connection to the DB
>
> ?>
>
> Any ideas? thanks.

You're using the same variable ($txt) for two different purposes.
You're saving all of your information from your database into $txt,
and then changing it to "PLEASE DO NOT REPLY TO THIS E-MAIL", and THEN
you send the e-mail.

Try changing this line:

$txt =3D "$row \n\r\n\rPLEASE DO NOT REPLY TO THIS EMAIL, THIS IS NOT A
VALID EMAIL ADDRESS"; // You're getting rid of everything that $txt
used to hold, and giving it this new value. ($row only existed for the
purposes of your while loop, and doesn't hold any information any
more)

to something like..

$body =3D "$txt \n\nPLEASE DO NOT..";

Also, you should save each field from your table into an array for
easier output.

Re: emailing data from my DB...??

am 29.12.2007 09:07:44 von Betikci Boris

On Dec 24, 3:50 pm, paul...@excite.com wrote:
> On Dec 21, 1:41 pm, Iv=E1n S=E1nchez Ortega >
>
>
> escomposlinux.-.punto.-.org> wrote:
> > paul...@excite.com wrote:
> > > On Dec 21, 1:05 pm, Iv=E1n S=E1nchez Ortega > > > escomposlinux.-.punto.-.org> wrote:
> > >> paul...@excite.com wrote:
> > >> > while ($row =3D mysql_fetch_array($result)) { // puts the values =
into
> > >> > $row
> > >> > print $row->editorialdate;
> > >> > print $row->editorialname;
> > >> > print $row->editorialcomments;
> > >> > }
> > >> [...]
> > >> > $txt =3D "$row[0] \n\r\n\rPLEASE DO NOT REPLY TO THIS EMAIL, THIS I=
S NOT
> > >> > A VALID EMAIL ADDRESS";
> > >> > $headers =3D "From: Daily_Prod._Rep...@company.com";
> > >> > mail($to,$subject,$txt,$headers); # <--- sends the email
> > >> [...]
> > >> > all I get is a blank email with no data in it from my database.
>
> > >> > Anyone have any ideas?
>
> > >> I'm not very sure *grin*, but maybe it's because you're printing the =
data
> > >> instead of storing it in the variable that will be fed to mail() ...
>
> > > How would I store it?
>
> > Geez.
>
> > $txt =3D '';
> > while ($row =3D mysql_fetch_array($result)) {
> > $txt .=3D $row->editorialdate;
> > $txt .=3D $row->editorialname;
> > $txt .=3D $row->editorialcomments;}
>
> > (snip)
> > mail($to,$subject,$txt,$headers);
>
> > --
> > ----------------------------------
> > Iv=E1n S=E1nchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
>
> > Proudly running Debian Linux with 2.6.22-3-amd64 kernel, KDE 3.5.8, and =
PHP
> > 5.2.4-2 generating this signature.
> > Uptime: 19:39:46 up 29 days, 5:55, 4 users, load average: 0.75, 1.34,=

> > 1.05
>
> I still can not get this to work...I've added your changes and still
> get a blank email.
>
> Generating and emailing report for:
> > $today =3D date("M j, Y,");
> echo $today;
>
> $host=3D"localhost";
> $user=3D"root";
> $pass=3D"";
> $db=3D"productiondb";
> $con =3D mysql_connect($host, $user, $pass);
> $txt =3D '';
>
> if (!$con)
> {
> die('Unable to connect: ' . mysql_error());
> }
> mysql_select_db($db, $con) or die('Unable to connect: ' .
> mysql_error());
>
> $sql =3D "SELECT * FROM editorial WHERE editorialdate LIKE '$today%' ";
>
> $result =3D mysql_query($sql,$con); // actually runs the query
>
> if (mysql_num_rows($result)) { // if there are results
> while ($row =3D mysql_fetch_array($result)) { // puts the values into
> $row
> $txt .=3D $row->editorialdate;
> $txt .=3D $row->editorialname;
> $txt .=3D $row->editorialcomments;
> }
>
> }
>
> //this part sends email
> ini_set("SMTP", "texchange.company.com");
> ini_set("smtp_port", "25");
> $to =3D "p...@company.com";
> $subject =3D "Production report";
> $txt =3D "$row \n\r\n\rPLEASE DO NOT REPLY TO THIS EMAIL, THIS IS NOT A
> VALID EMAIL ADDRESS";
> $headers =3D "From: Daily_Prod._Rep...@company.com";
> mail($to,$subject,$txt,$headers); # <--- sends the email
>
> mysql_close($con); //closes the connection to the DB
>
> ?>
>
> Any ideas? thanks.

What? Blank or "PLEASE DO NOT REPLY TO THIS EMAIL, THIS IS NOT A
VALID EMAIL ADDRESS"?

I don't test it but it seems you set a new value to $txt variable then
all rowing stuff is being gone.. ;)
What about putting $txt "the do not reply message" above the while
block?