I am copying out a script example from my text. It is an invoice system that lets you create an invoice, view it by invoice number, and back it up. It is not a homework assignment, it is one of those follow along examples in the text.
I have gone through and created a mock invoice. When I attempt to view the open invoice I am getting the following error:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\xampp\htdocs\Chapter.06\Chapter\ViewOpenInvoices.php on line 27
When I attempt to view the invoice by invoice number, I am getting the following error:
Parse error: syntax error, unexpected '>' in C:\xampp\htdocs\Chapter.06\Chapter\ViewInvoice.php on line 40
When I attempt to back up the directory that gets created, I am getting the following error:
Parse error: syntax error, unexpected '>' in C:\xampp\htdocs\Chapter.06\Chapter\ViewInvoice.php on line 40
I have gone through and received the solution from my instructor and compared what I entered to the solution and it is identical. I don't know where the errors are as there is nothing that is standing out.
Can someone proof what I have done and maybe you'll see something that I have missed.
Since there are many files, I have added them as a .zip and showed the code for viewopeninvoices.php and viewinvoice.php.
Thanks in advance!
Code for ViewOpenInvoices.php
CODE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>View Open Invoices</title>
<link rel="stylesheet" href="php_styles.css" type="text/css" />
<meta http-equiv="content-type"
content="texthtml; charset=iso-8859-1" />
</head>
<body>
<?php
$Dir = "open";
if (is_dir($Dir))
{
$DirEntries = scandir($Dir);
foreach ($DirEntries as $Entry)
{
if (strpos($Entry, '.txt') !== FALSE)
echo $Entry . "<br />";
}
}
else
echo ",p>The Open directory does not exist! You must first
save an invoice to crate the Open Directory.</p>;
?>
<hr />
<p><a href="Invoices.html">Return to Main Invoices Page</a></p>
</body>
</html>
Code for ViewInvoice.php
CODE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>View Invoice</title>
<link rel="stylesheet" href="php_styles.css" type="text/css" />
<meta http-equiv="content-type"
content="texthtml; charset=iso-8859-1" />
</head>
<body>
<?php
if (empty($_GET['invoicenum']))
echo "<hr /><p>You must enter an existing invoice number.
Click your browser's Back button to return to the
Invoices page.</p><hr />";
else if (is_readable("Open\\" . $_GET['invoicenum'] . ".txt"))
{
$InvoiceFields = fopen("Open\\" . $_GET['invoicenum'] . ".txt", "r");
$BillTo = fgets($InvoiceFields);
$FixBillTo = explode("~", $BillTo);
$BillTo = implode("\n, $FixBillTo);
$BillTo = stripslashes($BillTo);
$InvoiceNum = stripslashes(fgets($InvoiceFields));
$Date = stripslashes(fgets($InvoiceFields));
$Terms = stripslashes(fgets($InvoiceFields));
$Description1 = stripslashes(fgets($InvoiceFields));
$Description2 = stripslashes(fgets($InvoiceFields));
$Description3 = stripslashes(fgets($InvoiceFields));
$Quantity1 = stripslashes(fgets($InvoiceFields));
$Quantity2 = stripslashes(fgets($InvoiceFields));
$Quantity3 = stripslashes(fgets($InvoiceFields));
$Rate1 = stripslashes(fgets($InvoiceFields));
$Rate2 = stripslashes(fgets($InvoiceFields));
$Rate3 = stripslashes(fgets($InvoiceFields));
$Amount1 = stripslashes(fgets($InvoiceFields));
$Amount2 = stripslashes(fgets($InvoiceFields));
$Amount3 = stripslashes(fgets($InvoiceFields));
$Total = stripslashes(fgets($InvoiceFields));
fclose($InvoiceFields);
echo "<h1>View Invoice</h1>";
echo "<hr /><br /><table frame='border' rules='rows'>";
echo "<tr><td><strong>Bill To</strong>";
echo "<pre>$BillTo</pre></td>";
echo "<td style='text-align: right' colspan='3'>";
echo "<br /><strong>Invoice #</strong>: $InvoiceNum<br />";
echo "<strong>Date</strong>: $Date<br />";
echo "<strong>Terms</strong>: $Terms</td></tr>";
echo "<tr>";
echo "<td><strong>Description</strong><br />$Description1<br />$Description2<br />$Description3</td>";
echo "<td style='text-align: right'><strong>Quantity</strong><br />$Quantity1<br />$Quantity2<br />$Quantity3</td>";
echo "<td style='text-align: right'><strong>Rate</strong><br />$$Rate1<br />$$Rate2<br />$$Rate3</td>";
echo "<td style='text-align: right'><strong>Amount</strong><br />$$Amount1<br />$$Amount2<br />$$Amount3</td></tr>";
echo "<tr><td colspan='4' style='text-align: right'><strong>TOTAL</strong>: $$Total</td></tr>";
echo "</table>";
}
else
echo "<p>Could not read the invoice!</p>";
?>
</body>
</html>
This post has been edited by JackOfAllTrades: 18 Oct, 2009 - 09:17 AM