473,624 Members | 1,957 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with this code..??

I am having a bit of a problem with some code....can someone give me
some suggestions?

Parse error: syntax error, unexpected '{' in C:\xampp\htdocs \production
\date2.php on line 28

line 28 is this line:
while($row = mysql_fetch_arr ay(mysql_query( $sql)) {

It is the first while..
HERE IS THE CODE:
Generating and emailing report for:
<?php
$today = date("M j, Y,");
echo $today;

$host="localhos t";
$user="root";
$pass="";
$db="production db";
$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());

// Get results from first table
$sql = "SELECT * FROM editorial WHERE editorialdate LIKE '$today%'
";
$sql2 = "SELECT * FROM prepress WHERE prepressdate LIKE '$today%' ";

// Begin our email body
$messageBody = "Production Report follows for all departments: /r/
n";
//if (mysql_num_rows ($result)) { // if there are results
// Add results from first query to email
while($row = mysql_fetch_arr ay(mysql_query( $sql)){
$messageBody .= "Editorial Date: " . $row['editorialdate'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Name: " . $row['editorialname'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Comments: " . $row['editorialcomme nts'];
$messageBody .= "/r/n";
}

// Add results from second query to email
while($row = mysql_fetch_arr ay(mysql_query( $sql2)) {
$messageBody .= "PrePress Date: " . $row['prepressdate'];
$messageBody .= "/r/n";
$messageBody .= "Prepress Name: " . $row['prepressname'];
$messageBody .= "/r/n";
$messageBody .= "Prepress Comments: " . $row['prepresscommen ts'];
$messageBody .= "/r/n";
}

// Send email
ini_set("SMTP", "texchange.comp any.com");
ini_set("smtp_p ort", "25");
mail("pa**@comp any.com","Produ ction Report",$messag eBody);

mysql_close($co n); //closes the connection to the DB
?>

thanks for any help
Jan 2 '08 #1
10 1673
On Jan 2, 9:16 am, paul...@excite. com wrote:
I am having a bit of a problem with some code....can someone give me
some suggestions?

Parse error: syntax error, unexpected '{' in C:\xampp\htdocs \production
\date2.php on line 28

line 28 is this line:
while($row = mysql_fetch_arr ay(mysql_query( $sql)) {

It is the first while..
HERE IS THE CODE:
Generating and emailing report for:
<?php
$today = date("M j, Y,");
echo $today;

$host="localhos t";
$user="root";
$pass="";
$db="production db";
$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());

// Get results from first table
$sql = "SELECT * FROM editorial WHERE editorialdate LIKE '$today%'
";
$sql2 = "SELECT * FROM prepress WHERE prepressdate LIKE '$today%' ";

// Begin our email body
$messageBody = "Production Report follows for all departments: /r/
n";

//if (mysql_num_rows ($result)) { // if there are results
// Add results from first query to email
while($row = mysql_fetch_arr ay(mysql_query( $sql)){
$messageBody .= "Editorial Date: " . $row['editorialdate'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Name: " . $row['editorialname'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Comments: " . $row['editorialcomme nts'];
$messageBody .= "/r/n";
}

// Add results from second query to email
while($row = mysql_fetch_arr ay(mysql_query( $sql2)) {
$messageBody .= "PrePress Date: " . $row['prepressdate'];
$messageBody .= "/r/n";
$messageBody .= "Prepress Name: " . $row['prepressname'];
$messageBody .= "/r/n";
$messageBody .= "Prepress Comments: " . $row['prepresscommen ts'];
$messageBody .= "/r/n";
}

// Send email
ini_set("SMTP", "texchange.comp any.com");
ini_set("smtp_p ort", "25");
mail("p...@comp any.com","Produ ction Report",$messag eBody);

mysql_close($co n); //closes the connection to the DB
?>

thanks for any help
I changed my code a bit because I did not have a couple ) and also
added if (mysql_num_rows ($result)) { // if there are results

Now I get this error on the last line of my code the last line is my: ?
>
the error is:
Parse error: syntax error, unexpected $end in C:\xampp\htdocs
\production\dat e2.php on line 54
Jan 2 '08 #2
On Jan 2, 9:26 am, paul...@excite. com wrote:
On Jan 2, 9:16 am, paul...@excite. com wrote:
I am having a bit of a problem with some code....can someone give me
some suggestions?
Parse error: syntax error, unexpected '{' in C:\xampp\htdocs \production
\date2.php on line 28
line 28 is this line:
while($row = mysql_fetch_arr ay(mysql_query( $sql)) {
It is the first while..
HERE IS THE CODE:
Generating and emailing report for:
<?php
$today = date("M j, Y,");
echo $today;
$host="localhos t";
$user="root";
$pass="";
$db="production db";
$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());
// Get results from first table
$sql = "SELECT * FROM editorial WHERE editorialdate LIKE '$today%'
";
$sql2 = "SELECT * FROM prepress WHERE prepressdate LIKE '$today%' ";
// Begin our email body
$messageBody = "Production Report follows for all departments: /r/
n";
//if (mysql_num_rows ($result)) { // if there are results
// Add results from first query to email
while($row = mysql_fetch_arr ay(mysql_query( $sql)){
$messageBody .= "Editorial Date: " . $row['editorialdate'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Name: " . $row['editorialname'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Comments: " . $row['editorialcomme nts'];
$messageBody .= "/r/n";
}
// Add results from second query to email
while($row = mysql_fetch_arr ay(mysql_query( $sql2)) {
$messageBody .= "PrePress Date: " . $row['prepressdate'];
$messageBody .= "/r/n";
$messageBody .= "Prepress Name: " . $row['prepressname'];
$messageBody .= "/r/n";
$messageBody .= "Prepress Comments: " . $row['prepresscommen ts'];
$messageBody .= "/r/n";
}
// Send email
ini_set("SMTP", "texchange.comp any.com");
ini_set("smtp_p ort", "25");
mail("p...@comp any.com","Produ ction Report",$messag eBody);
mysql_close($co n); //closes the connection to the DB
?>
thanks for any help

I changed my code a bit because I did not have a couple ) and also
added if (mysql_num_rows ($result)) { // if there are results

Now I get this error on the last line of my code the last line is my: ?

the error is:
Parse error: syntax error, unexpected $end in C:\xampp\htdocs
\production\dat e2.php on line 54
Sorry, forgot to include the updated code:
Generating and emailing report for:
<?php
$today = date("M j, Y,");
echo $today;

$host="localhos t";
$user="root";
$pass="";
$db="production db";
$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());

// Get results from first table
$sql = "SELECT * FROM editorial WHERE editorialdate LIKE '$today%'
";
$sql2 = "SELECT * FROM prepress WHERE prepressdate LIKE '$today%' ";

// Begin our email body
$messageBody = "Production Report follows for all departments: /r/
n";
if (mysql_num_rows ($result)) { // if there are results
// Add results from first query to email
while($row = mysql_fetch_arr ay(mysql_query( $sql))){
$messageBody .= "Editorial Date: " . $row['editorialdate'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Name: " . $row['editorialname'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Comments: " . $row['editorialcomme nts'];
$messageBody .= "/r/n";
}

// Add results from second query to email
while($row = mysql_fetch_arr ay(mysql_query( $sql2))) {
$messageBody .= "PrePress Date: " . $row['prepressdate'];
$messageBody .= "/r/n";
$messageBody .= "Prepress Name: " . $row['prepressname'];
$messageBody .= "/r/n";
$messageBody .= "Prepress Comments: " . $row['prepresscommen ts'];
$messageBody .= "/r/n";
}

mysql_close($co n); //closes the connection to the DB

// Send email
ini_set("SMTP", "texchange.comp any.com");
ini_set("smtp_p ort", "25");
mail("pa**@comp any.com","Produ ction Report",$messag eBody);
?>
Jan 2 '08 #3
In article
<52************ *************** *******@e50g200 0hsh.googlegrou ps.com>,
pa*****@excite. com wrote:
On Jan 2, 9:26 am, paul...@excite. com wrote:
On Jan 2, 9:16 am, paul...@excite. com wrote:
I am having a bit of a problem with some code....can someone give me
some suggestions?
Parse error: syntax error, unexpected '{' in C:\xampp\htdocs \production
\date2.php on line 28
line 28 is this line:
while($row = mysql_fetch_arr ay(mysql_query( $sql)) {
It is the first while..
HERE IS THE CODE:
Generating and emailing report for:
<?php
$today = date("M j, Y,");
echo $today;
$host="localhos t";
$user="root";
$pass="";
$db="production db";
$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());
// Get results from first table
$sql = "SELECT * FROM editorial WHERE editorialdate LIKE '$today%'
";
$sql2 = "SELECT * FROM prepress WHERE prepressdate LIKE '$today%' ";
// Begin our email body
$messageBody = "Production Report follows for all departments: /r/
n";
//if (mysql_num_rows ($result)) { // if there are results
// Add results from first query to email
while($row = mysql_fetch_arr ay(mysql_query( $sql)){
$messageBody .= "Editorial Date: " . $row['editorialdate'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Name: " . $row['editorialname'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Comments: " .
$row['editorialcomme nts'];
$messageBody .= "/r/n";
}
// Add results from second query to email
while($row = mysql_fetch_arr ay(mysql_query( $sql2)) {
$messageBody .= "PrePress Date: " . $row['prepressdate'];
$messageBody .= "/r/n";
$messageBody .= "Prepress Name: " . $row['prepressname'];
$messageBody .= "/r/n";
$messageBody .= "Prepress Comments: " . $row['prepresscommen ts'];
$messageBody .= "/r/n";
}
// Send email
ini_set("SMTP", "texchange.comp any.com");
ini_set("smtp_p ort", "25");
mail("p...@comp any.com","Produ ction Report",$messag eBody);
mysql_close($co n); //closes the connection to the DB
?>
thanks for any help
I changed my code a bit because I did not have a couple ) and also
added if (mysql_num_rows ($result)) { // if there are results

Now I get this error on the last line of my code the last line is my: ?

the error is:
Parse error: syntax error, unexpected $end in C:\xampp\htdocs
\production\dat e2.php on line 54

Sorry, forgot to include the updated code:
Generating and emailing report for:
<?php
$today = date("M j, Y,");
echo $today;

$host="localhos t";
$user="root";
$pass="";
$db="production db";
$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());

// Get results from first table
$sql = "SELECT * FROM editorial WHERE editorialdate LIKE '$today%'
";
$sql2 = "SELECT * FROM prepress WHERE prepressdate LIKE '$today%' ";

// Begin our email body
$messageBody = "Production Report follows for all departments: /r/
n";
if (mysql_num_rows ($result)) { // if there are results
This 'if' has no closing }

I always give the { and the } the same indentation so it's easy to see
that one is missing:

if (mysql_num_rows ($result))
{
// if there are results
// Add results from first query to email
while ($row = mysql_fetch_arr ay(mysql_query( $sql)))
{
$messageBody .= "Editorial Date: " . $row['editorialdate'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Name: " . $row['editorialname'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Comments: " .
$row['editorialcomme nts'];
$messageBody .= "/r/n";
}

// Add results from second query to email
while ($row = mysql_fetch_arr ay(mysql_query( $sql2)))
{
$messageBody .= "PrePress Date: " . $row['prepressdate'];
$messageBody .= "/r/n";
$messageBody .= "Prepress Name: " . $row['prepressname'];
$messageBody .= "/r/n";
$messageBody .= "Prepress Comments: " .
$row['prepresscommen ts'];
$messageBody .= "/r/n";
}

<--------- where's the } ????

mysql_close($co n); //closes the connection to the DB

// Send email
ini_set("SMTP", "texchange.comp any.com");
ini_set("smtp_p ort", "25");
mail("pa**@comp any.com","Produ ction Report",$messag eBody);

?>
Jan 2 '08 #4
On Jan 2, 9:53 am, Tim Streater <tim.strea...@d ante.org.ukwrot e:
In article
<52120bfd-b2a0-4b8f-a3e6-f96cf2793...@e5 0g2000hsh.googl egroups.com>,

paul...@excite. com wrote:
On Jan 2, 9:26 am, paul...@excite. com wrote:
On Jan 2, 9:16 am, paul...@excite. com wrote:
I am having a bit of a problem with some code....can someone give me
some suggestions?
Parse error: syntax error, unexpected '{' in C:\xampp\htdocs \production
\date2.php on line 28
line 28 is this line:
while($row = mysql_fetch_arr ay(mysql_query( $sql)) {
It is the first while..
HERE IS THE CODE:
Generating and emailing report for:
<?php
$today = date("M j, Y,");
echo $today;
$host="localhos t";
$user="root";
$pass="";
$db="production db";
$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());
// Get results from first table
$sql = "SELECT * FROM editorial WHERE editorialdate LIKE '$today%'
";
$sql2 = "SELECT * FROM prepress WHERE prepressdate LIKE '$today%' ";
// Begin our email body
$messageBody = "Production Report follows for all departments: /r/
n";
//if (mysql_num_rows ($result)) { // if there are results
// Add results from first query to email
while($row = mysql_fetch_arr ay(mysql_query( $sql)){
$messageBody .= "Editorial Date: " . $row['editorialdate'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Name: " . $row['editorialname'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Comments: " .
$row['editorialcomme nts'];
$messageBody .= "/r/n";
}
// Add results from second query to email
while($row = mysql_fetch_arr ay(mysql_query( $sql2)) {
$messageBody .= "PrePress Date: " . $row['prepressdate'];
$messageBody .= "/r/n";
$messageBody .= "Prepress Name: " . $row['prepressname'];
$messageBody .= "/r/n";
$messageBody .= "Prepress Comments: " . $row['prepresscommen ts'];
$messageBody .= "/r/n";
}
// Send email
ini_set("SMTP", "texchange.comp any.com");
ini_set("smtp_p ort", "25");
mail("p...@comp any.com","Produ ction Report",$messag eBody);
mysql_close($co n); //closes the connection to the DB
?>
thanks for any help
I changed my code a bit because I did not have a couple ) and also
added if (mysql_num_rows ($result)) { // if there are results
Now I get this error on the last line of my code the last line is my: ?
the error is:
Parse error: syntax error, unexpected $end in C:\xampp\htdocs
\production\dat e2.php on line 54
Sorry, forgot to include the updated code:
Generating and emailing report for:
<?php
$today = date("M j, Y,");
echo $today;
$host="localhos t";
$user="root";
$pass="";
$db="production db";
$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());
// Get results from first table
$sql = "SELECT * FROM editorial WHERE editorialdate LIKE '$today%'
";
$sql2 = "SELECT * FROM prepress WHERE prepressdate LIKE '$today%' ";
// Begin our email body
$messageBody = "Production Report follows for all departments: /r/
n";
if (mysql_num_rows ($result)) { // if there are results

This 'if' has no closing }

I always give the { and the } the same indentation so it's easy to see
that one is missing:

if (mysql_num_rows ($result))
{
// if there are results
// Add results from first query to email
while ($row = mysql_fetch_arr ay(mysql_query( $sql)))
{
$messageBody .= "Editorial Date: " . $row['editorialdate'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Name: " . $row['editorialname'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Comments: " .
$row['editorialcomme nts'];
$messageBody .= "/r/n";
}

// Add results from second query to email
while ($row = mysql_fetch_arr ay(mysql_query( $sql2)))
{
$messageBody .= "PrePress Date: " . $row['prepressdate'];
$messageBody .= "/r/n";
$messageBody .= "Prepress Name: " . $row['prepressname'];
$messageBody .= "/r/n";
$messageBody .= "Prepress Comments: " .
$row['prepresscommen ts'];
$messageBody .= "/r/n";
}

<--------- where's the } ????

mysql_close($co n); //closes the connection to the DB

// Send email
ini_set("SMTP", "texchange.comp any.com");
ini_set("smtp_p ort", "25");
mail("p...@comp any.com","Produ ction Report",$messag eBody);

?>
OK I think I am getting closer, thanks for the help.
I am getting this error:
Warning: mysql_num_rows( ): supplied argument is not a valid MySQL
result resource in C:\xampp\htdocs \production\dat e2.php on line 26

this is my code as of now:
Generating and emailing report for:
<?php
$today = date("M j, Y,");
echo $today;

$host="localhos t";
$user="root";
$pass="";
$db="production db";
$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());

// Get results from first table
$sql = "SELECT * FROM editorial WHERE editorialdate LIKE '$today%'
";
$sql2 = "SELECT * FROM prepress WHERE prepressdate LIKE '$today%' ";

// Begin our email body
$messageBody = "Production Report follows for all departments: /r/
n";
if (mysql_num_rows ($result)) { // if there are results
// Add results from first query to email
while($row = mysql_fetch_arr ay(mysql_query( $sql))){
$messageBody .= "Editorial Date: " . $row['editorialdate'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Name: " . $row['editorialname'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Comments: " . $row['editorialcomme nts'];
$messageBody .= "/r/n";
}

// Add results from second query to email
while($row = mysql_fetch_arr ay(mysql_query( $sql2))) {
$messageBody .= "PrePress Date: " . $row['prepressdate'];
$messageBody .= "/r/n";
$messageBody .= "Prepress Name: " . $row['prepressname'];
$messageBody .= "/r/n";
$messageBody .= "Prepress Comments: " . $row['prepresscommen ts'];
$messageBody .= "/r/n";
}
}

mysql_close($co n); //closes the connection to the DB

// Send email
ini_set("SMTP", "texchange.comp any.com");
ini_set("smtp_p ort", "25");
$headers = "From: Pr************* *****@company.c om";
mail("pa**@comp any.com","Produ ction Report",$messag eBody,$headers) ;
?>

And I do get an email, all that is in the email though is:
Production Report follows for all departments: /r/n
Jan 2 '08 #5
pa*****@excite. com wrote:
OK I think I am getting closer, thanks for the help.
I am getting this error:
Warning: mysql_num_rows( ): supplied argument is not a valid MySQL
result resource in C:\xampp\htdocs \production\dat e2.php on line 26
Thats because you never made a query at all.

this is my code as of now:
Generating and emailing report for:
<?php
$today = date("M j, Y,");
echo $today;

$host="localhos t";
$user="root";
$pass="";
$db="production db";
$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());

// Get results from first table
$sql = "SELECT * FROM editorial WHERE editorialdate LIKE '$today%'
";
$sql2 = "SELECT * FROM prepress WHERE prepressdate LIKE '$today%' ";

// Begin our email body
$messageBody = "Production Report follows for all departments: /r/
n";
//You need a
$result=mysql_q uery($sql); // in here
>
if (mysql_num_rows ($result)) { // if there are results
// Add results from first query to email
while($row = mysql_fetch_arr ay(mysql_query( $sql))){
$messageBody .= "Editorial Date: " . $row['editorialdate'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Name: " . $row['editorialname'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Comments: " . $row['editorialcomme nts'];
$messageBody .= "/r/n";
}

// Add results from second query to email
while($row = mysql_fetch_arr ay(mysql_query( $sql2))) {
$messageBody .= "PrePress Date: " . $row['prepressdate'];
$messageBody .= "/r/n";
$messageBody .= "Prepress Name: " . $row['prepressname'];
$messageBody .= "/r/n";
$messageBody .= "Prepress Comments: " . $row['prepresscommen ts'];
$messageBody .= "/r/n";
}
}

mysql_close($co n); //closes the connection to the DB

// Send email
ini_set("SMTP", "texchange.comp any.com");
ini_set("smtp_p ort", "25");
$headers = "From: Pr************* *****@company.c om";
mail("pa**@comp any.com","Produ ction Report",$messag eBody,$headers) ;
?>

And I do get an email, all that is in the email though is:
Production Report follows for all departments: /r/n
Jan 2 '08 #6
On Jan 2, 12:18 pm, The Natural Philosopher <a...@b.cwrot e:
paul...@excite. com wrote:
OK I think I am getting closer, thanks for the help.
I am getting this error:
Warning: mysql_num_rows( ): supplied argument is not a valid MySQL
result resource in C:\xampp\htdocs \production\dat e2.php on line 26

Thats because you never made a query at all.
this is my code as of now:
Generating and emailing report for:
<?php
$today = date("M j, Y,");
echo $today;
$host="localhos t";
$user="root";
$pass="";
$db="production db";
$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());
// Get results from first table
$sql = "SELECT * FROM editorial WHERE editorialdate LIKE '$today%'
";
$sql2 = "SELECT * FROM prepress WHERE prepressdate LIKE '$today%' ";
// Begin our email body
$messageBody = "Production Report follows for all departments: /r/
n";

//You need a
$result=mysql_q uery($sql); // in here
if (mysql_num_rows ($result)) { // if there are results
// Add results from first query to email
while($row = mysql_fetch_arr ay(mysql_query( $sql))){
$messageBody .= "Editorial Date: " . $row['editorialdate'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Name: " . $row['editorialname'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Comments: " . $row['editorialcomme nts'];
$messageBody .= "/r/n";
}
// Add results from second query to email
while($row = mysql_fetch_arr ay(mysql_query( $sql2))) {
$messageBody .= "PrePress Date: " . $row['prepressdate'];
$messageBody .= "/r/n";
$messageBody .= "Prepress Name: " . $row['prepressname'];
$messageBody .= "/r/n";
$messageBody .= "Prepress Comments: " . $row['prepresscommen ts'];
$messageBody .= "/r/n";
}
}
mysql_close($co n); //closes the connection to the DB
// Send email
ini_set("SMTP", "texchange.comp any.com");
ini_set("smtp_p ort", "25");
$headers = "From: Prod.Report_PRE PR...@company.c om";
mail("p...@comp any.com","Produ ction Report",$messag eBody,$headers) ;
?>
And I do get an email, all that is in the email though is:
Production Report follows for all departments: /r/n
so will I need one of these IF statements before each one of my:
while($row = mysql_fetch_arr ay(mysql_query( $sql))){

and then do I also need multiple:
$result=mysql_q uery($sql);
only use $sql2 etc?
Jan 2 '08 #7
In article
<fc************ *************** *******@j20g200 0hsi.googlegrou ps.com>,
pa*****@excite. com wrote:

[snip]
>
OK I think I am getting closer, thanks for the help.
I am getting this error:
Warning: mysql_num_rows( ): supplied argument is not a valid MySQL
result resource in C:\xampp\htdocs \production\dat e2.php on line 26

this is my code as of now:
Generating and emailing report for:
<?php
$today = date("M j, Y,");
echo $today;

$host="localhos t";
$user="root";
$pass="";
$db="production db";
$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());

// Get results from first table
$sql = "SELECT * FROM editorial WHERE editorialdate LIKE '$today%'
";
$sql2 = "SELECT * FROM prepress WHERE prepressdate LIKE '$today%' ";

// Begin our email body
$messageBody = "Production Report follows for all departments: /r/
n";
<----- try doing a query *before* asking how many rows it generated.

$result = mysql_query ($sql);
$numrows = mysql_num_rows ($result);
if ($numrows>0)
{
while ($row = mysql_fetch_arr ay ($result))
{
// add first results
...
}
}
mysql_free_resu lt ($result);

// now do the same for the other query

if (mysql_num_rows ($result)) { // if there are results
// Add results from first query to email
while($row = mysql_fetch_arr ay(mysql_query( $sql))){
$messageBody .= "Editorial Date: " . $row['editorialdate'];

How do you expect this to work? Every time round the while loop, you do
the mysql_query again and fetch the first row of the results. You
shouldn't nest these calls.

I would also suggest a more tidy layout which will help you debug more
easily.
Jan 2 '08 #8
In article
<19************ *************** *******@x69g200 0hsx.googlegrou ps.com>,
pa*****@excite. com wrote:

[snip]
if (mysql_num_rows ($result)) { // if there are results
// Add results from first query to email
while($row = mysql_fetch_arr ay(mysql_query( $sql))){
$messageBody .= "Editorial Date: " . $row['editorialdate'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Name: " . $row['editorialname'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Comments: " . $row['editorialcomme nts'];
$messageBody .= "/r/n";
}
// Add results from second query to email
while($row = mysql_fetch_arr ay(mysql_query( $sql2))) {
$messageBody .= "PrePress Date: " . $row['prepressdate'];
$messageBody .= "/r/n";
$messageBody .= "Prepress Name: " . $row['prepressname'];
$messageBody .= "/r/n";
$messageBody .= "Prepress Comments: " . $row['prepresscommen ts'];
$messageBody .= "/r/n";
}
}
mysql_close($co n); //closes the connection to the DB
// Send email
ini_set("SMTP", "texchange.comp any.com");
ini_set("smtp_p ort", "25");
$headers = "From: Prod.Report_PRE PR...@company.c om";
mail("p...@comp any.com","Produ ction Report",$messag eBody,$headers) ;
?>
And I do get an email, all that is in the email though is:
Production Report follows for all departments: /r/n

so will I need one of these IF statements before each one of my:
while($row = mysql_fetch_arr ay(mysql_query( $sql))){

and then do I also need multiple:
$result=mysql_q uery($sql);
only use $sql2 etc?
If you don't do a query, you won't have any results. If you have two
query strings, you obviously gotta do two queries.

If you got two queries, you got to check each one to see if it returned
any results. Why do you think the first IF which covers the first query,
should also cover the second?
Jan 2 '08 #9
On Jan 2, 12:33 pm, Tim Streater <tim.strea...@d ante.org.ukwrot e:
In article
<fc01e709-a824-4662-a4f3-1d5fad0d5...@j2 0g2000hsi.googl egroups.com>,

paul...@excite. com wrote:

[snip]


OK I think I am getting closer, thanks for the help.
I am getting this error:
Warning: mysql_num_rows( ): supplied argument is not a valid MySQL
result resource in C:\xampp\htdocs \production\dat e2.php on line 26
this is my code as of now:
Generating and emailing report for:
<?php
$today = date("M j, Y,");
echo $today;
$host="localhos t";
$user="root";
$pass="";
$db="production db";
$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());
// Get results from first table
$sql = "SELECT * FROM editorial WHERE editorialdate LIKE '$today%'
";
$sql2 = "SELECT * FROM prepress WHERE prepressdate LIKE '$today%' ";
// Begin our email body
$messageBody = "Production Report follows for all departments: /r/
n";

<----- try doing a query *before* asking how many rows it generated.

$result = mysql_query ($sql);
$numrows = mysql_num_rows ($result);
if ($numrows>0)
{
while ($row = mysql_fetch_arr ay ($result))
{
// add first results
...
}
}
mysql_free_resu lt ($result);

// now do the same for the other query
if (mysql_num_rows ($result)) { // if there are results
// Add results from first query to email
while($row = mysql_fetch_arr ay(mysql_query( $sql))){
$messageBody .= "Editorial Date: " . $row['editorialdate'];

How do you expect this to work? Every time round the while loop, you do
the mysql_query again and fetch the first row of the results. You
shouldn't nest these calls.

I would also suggest a more tidy layout which will help you debug more
easily.
OK I am seeing this now, after adding this:
$result=mysql_q uery($sql);
It looks like my page is just in a loop, because it just continues to
try to load.

Looking at this code I think it will loop through and do a search on
$SQL until it does not find any other records matching, than it will
go down and do the same thing for $sql2 while there is something
there, all the time putting it into $messagebody

Am I close? What am I doing wrong?
most updated code as of now...now it looks like the page is just
looping......
Generating and emailing report for:
<?php
$today = date("M j, Y,");
echo $today;

$host="localhos t";
$user="root";
$pass="";
$db="production db";
$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());

// Get results from first table
$sql = "SELECT * FROM editorial WHERE editorialdate LIKE '$today%'
";
$sql2 = "SELECT * FROM prepress WHERE prepressdate LIKE '$today%' ";

// Begin our email body
$messageBody = "Production Report follows for all departments: /r/
n";
$result=mysql_q uery($sql);

if (mysql_num_rows ($result)) { // if there are results

// Add results from first query to email

while($row = mysql_fetch_arr ay(mysql_query( $sql))){
$messageBody .= "Editorial Date: " . $row['editorialdate'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Name: " . $row['editorialname'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Comments: " . $row['editorialcomme nts'];
$messageBody .= "/r/n";
}

// Add results from second query to email
while($row = mysql_fetch_arr ay(mysql_query( $sql2))) {
$messageBody .= "PrePress Date: " . $row['prepressdate'];
$messageBody .= "/r/n";
$messageBody .= "Prepress Name: " . $row['prepressname'];
$messageBody .= "/r/n";
$messageBody .= "Prepress Comments: " . $row['prepresscommen ts'];
$messageBody .= "/r/n";
}
}
mysql_close($co n); //closes the connection to the DB

// Send email
ini_set("SMTP", "texchange.comp any.com");
ini_set("smtp_p ort", "25");
$headers = "From: Pr************* *****@company.c om";
mail("pa**@comp any.com","Produ ction Report",$messag eBody,$headers) ;
?>
Jan 2 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3098
by: Bruce W...1 | last post by:
In my effort to learn PHP I'm playing with some simple email scripts. They worked a few days ago but they stopped working. The only thing I've done to this Windows 2000 PC in this time was a Windows Update which I do regularly. The only part of this update that might be related was an IE 6 update. So I uninstalled and reinstaled PHP 4.3.3. The mail server setting is correct in the php.ini file. But email is still not being sent. ...
21
4402
by: BlackHawke | last post by:
My name is Nick Soutter, I own a small game development company (www.aepoxgames.net) making our first game (www.andromedaonline.net) in java. I am writing because we are having a very serious problem, and I was hoping someone might have thoughts.
11
3749
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class (ClassB* b; b->func(); ) the base-class function is called instead of the new function in the derived class. All other similar functions (virtual in the base class and overwritten in the the derived class) work fine, it's just this one function. ...
3
1961
by: Christopher M. Lusardi | last post by:
Hello, THE PROBLEM ----------- If I compile parts of my program with CC, and C, using extern "C" as appropriate it compiles without any errors, but it does a segmentation fault when I run the program. The variables involved in the segmentation fault are surrounded by compiler directives. I am 100% sure that I do not have to extern "C"
13
1422
by: John | last post by:
Hi all: In my code I define a class with inline constructor. But it does not work. I describe the class as below: myclass{ public: myclass(int a, int b) { r1 = a; r2 = b;} protected:
18
1842
by: bArT | last post by:
Hi! I have a problem with such situation. I have a class like below and have some pointers (ptr1 and ptr2). I dynamically allocate memory in constructor and I free in destructor. For one pointer there is some error when dustroctor delete objects. Why? What should I have to change? Please help. bart
9
1578
by: babak | last post by:
Hi everybody I'm working with a project in embedded Visual Studio 4 and I have a general problem which I hope that somebody can help me with. My problem is the following: My project works fine in debug version but behaves strangely and sometimes crashes when I run it in release version. I suspect that it is some sort of memory problem but it is not that easy to find out what the problem exactly is (the project is rather big with maybe...
14
1646
by: Harry | last post by:
Good Day, Here is a structure that i am using in my code typedef struct storable_picture { PictureStructure structure; int poc;
8
1277
by: Rinaldo | last post by:
Hi, When I start my program in the debugger, there is no problem, but when not I get an exception. It appears in: private void Upload(string filename, string FTnaam) { MessageBox.Show("in upload.");
6
2142
by: pkchandra999 | last post by:
My Server OS : Centos 64 bit Apache version is Apache v2.2.9 Php Version : 5.2.5 I am providing feeds to my forum through RSS. The feeds are in html and those feeds will be parsed to bbcode of the forum. In my forum the feeds are not parsed to bbcode and it actually posting the html code into the thread in a strange way. IT is removing the <> tags for each html code and posting it in thread.
1
8336
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8478
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7164
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6111
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2607
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1786
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1485
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.