Reply to Re: problem with this code..??

Your name:

Reply:


Posted by paul814 on 01/02/08 17:09

On Jan 2, 9:53 am, Tim Streater <tim.strea...@dante.org.uk> wrote:
> In article
> <52120bfd-b2a0-4b8f-a3e6-f96cf2793...@e50g2000hsh.googlegroups.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_array(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="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());
>
> > > > // 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_array(mysql_query($sql)){
> > > > $messageBody .= "Editorial Date: " . $row['editorialdate'];
> > > > $messageBody .= "/r/n";
> > > > $messageBody .= "Editorial Name: " . $row['editorialname'];
> > > > $messageBody .= "/r/n";
> > > > $messageBody .= "Editorial Comments: " .
> > > > $row['editorialcomments'];
> > > > $messageBody .= "/r/n";
> > > > }
>
> > > > // Add results from second query to email
> > > > while($row = mysql_fetch_array(mysql_query($sql2)) {
> > > > $messageBody .= "PrePress Date: " . $row['prepressdate'];
> > > > $messageBody .= "/r/n";
> > > > $messageBody .= "Prepress Name: " . $row['prepressname'];
> > > > $messageBody .= "/r/n";
> > > > $messageBody .= "Prepress Comments: " . $row['prepresscomments'];
> > > > $messageBody .= "/r/n";
> > > > }
>
> > > > // Send email
> > > > ini_set("SMTP", "texchange.company.com");
> > > > ini_set("smtp_port", "25");
> > > > mail("p...@company.com","Production Report",$messageBody);
>
> > > > mysql_close($con); //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\date2.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="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());
>
> > // 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_array(mysql_query($sql)))
> {
> $messageBody .= "Editorial Date: " . $row['editorialdate'];
> $messageBody .= "/r/n";
> $messageBody .= "Editorial Name: " . $row['editorialname'];
> $messageBody .= "/r/n";
> $messageBody .= "Editorial Comments: " .
> $row['editorialcomments'];
> $messageBody .= "/r/n";
> }
>
> // Add results from second query to email
> while ($row = mysql_fetch_array(mysql_query($sql2)))
> {
> $messageBody .= "PrePress Date: " . $row['prepressdate'];
> $messageBody .= "/r/n";
> $messageBody .= "Prepress Name: " . $row['prepressname'];
> $messageBody .= "/r/n";
> $messageBody .= "Prepress Comments: " .
> $row['prepresscomments'];
> $messageBody .= "/r/n";
> }
>
> <--------- where's the } ????
>
> mysql_close($con); //closes the connection to the DB
>
> // Send email
> ini_set("SMTP", "texchange.company.com");
> ini_set("smtp_port", "25");
> mail("p...@company.com","Production Report",$messageBody);
>
> ?>

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\date2.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="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());

// 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_array(mysql_query($sql))){
$messageBody .= "Editorial Date: " . $row['editorialdate'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Name: " . $row['editorialname'];
$messageBody .= "/r/n";
$messageBody .= "Editorial Comments: " . $row['editorialcomments'];
$messageBody .= "/r/n";
}

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

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

// Send email
ini_set("SMTP", "texchange.company.com");
ini_set("smtp_port", "25");
$headers = "From: Prod.Report_PREPRESS@company.com";
mail("paul@company.com","Production Report",$messageBody,$headers);
?>

And I do get an email, all that is in the email though is:
Production Report follows for all departments: /r/n

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация