PHP School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a PHP Expert!

Join 307,220 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,650 people online right now. Registration is fast and FREE... Join Now!




Getting parse errors in PHP script

 

Getting parse errors in PHP script, Confirmed that it is identical to the solution but still getting error

greenbluekidz

17 Oct, 2009 - 10:57 AM
Post #1

New D.I.C Head
*

Joined: 5 Jan, 2009
Posts: 49


My Contributions
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

User is offlineProfile CardPM
+Quote Post


ahmad_511

RE: Getting Parse Errors In PHP Script

17 Oct, 2009 - 12:11 PM
Post #2

MSX
Group Icon

Joined: 28 Apr, 2007
Posts: 515



Thanked: 38 times
Dream Kudos: 500
My Contributions
Hi,
QUOTE

php

echo ",p>The Open directory does not exist! You must first
save an invoice to crate the Open Directory.</p>;



the opening tag should be <p>
and you missed the double quote at the of echo.
php

echo "<p>The Open directory does not exist! You must first
save an invoice to crate the Open Directory.</p>";

User is offlineProfile CardPM
+Quote Post

BlissC

RE: Getting Parse Errors In PHP Script

17 Oct, 2009 - 12:26 PM
Post #3

New D.I.C Head
Group Icon

Joined: 27 Sep, 2009
Posts: 34



Thanked: 1 times
Dream Kudos: 25
My Contributions
I know you've got the answer to your query already, but I found this article yesteday while I was searching for a solution for a problem I'd got with a PHP script, and bookmarked it, as I always find it difficult to fathom out PHP's error messages. I've found it's been helpful for me over the last couple of days, helping to explain those error messages that often don't seem to make much sense: http://www.phpreferencebook.com/misc/php-e...ommon-mistakes/
User is offlineProfile CardPM
+Quote Post

greenbluekidz

RE: Getting Parse Errors In PHP Script

17 Oct, 2009 - 01:08 PM
Post #4

New D.I.C Head
*

Joined: 5 Jan, 2009
Posts: 49


My Contributions
QUOTE(BlissC @ 17 Oct, 2009 - 12:26 PM) *

I know you've got the answer to your query already, but I found this article yesteday while I was searching for a solution for a problem I'd got with a PHP script, and bookmarked it, as I always find it difficult to fathom out PHP's error messages. I've found it's been helpful for me over the last couple of days, helping to explain those error messages that often don't seem to make much sense: http://www.phpreferencebook.com/misc/php-e...ommon-mistakes/



Thanks for this link! I have bookmarked it!

ahmad_511

I have fixed what you noticed and I am no longer getting errors when I attempt to view open invoices. Thanks for that!!
I am still getting errors when attempting to backup invoices.
The error I am getting is:

Parse error: syntax error, unexpected '>' in C:\xampp\htdocs\Chapter.06\Chapter\ViewInvoice.php on line 40



User is offlineProfile CardPM
+Quote Post

greenbluekidz

RE: Getting Parse Errors In PHP Script

17 Oct, 2009 - 07:10 PM
Post #5

New D.I.C Head
*

Joined: 5 Jan, 2009
Posts: 49


My Contributions
QUOTE(greenbluekidz @ 17 Oct, 2009 - 01:08 PM) *

QUOTE(BlissC @ 17 Oct, 2009 - 12:26 PM) *

I know you've got the answer to your query already, but I found this article yesteday while I was searching for a solution for a problem I'd got with a PHP script, and bookmarked it, as I always find it difficult to fathom out PHP's error messages. I've found it's been helpful for me over the last couple of days, helping to explain those error messages that often don't seem to make much sense: http://www.phpreferencebook.com/misc/php-e...ommon-mistakes/



Thanks for this link! I have bookmarked it!

ahmad_511

I have fixed what you noticed and I am no longer getting errors when I attempt to view open invoices. Thanks for that!!
I am still getting errors when attempting to backup invoices.
The error I am getting is:

Parse error: syntax error, unexpected '>' in C:\xampp\htdocs\Chapter.06\Chapter\ViewInvoice.php on line 40


Everything works now after reviewing the code again.

Thanks for the assistance!
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 10:25PM

Live PHP Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month