geekette Posted April 3, 2009 Share Posted April 3, 2009 Hi! I'm new to PHP so apologies if I'm asking noob-like questions. I wrote out and ran the following code and received an error on line 37. Unfortunately, using terminal to debug is inefficient. Any help would be appreciated!..: <!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>Save Invoice</title> <link rel="stylesheet" href="php_styles.css" type="text/css" /> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> </head> <body> <?php $BillTo = $_POST["billto"]; $Date = $_POST["date"]; $Terms = $_POST["terms"]; $Description1 = $_POST["description1"]; $Description2 = $_POST["description2"]; $Description3 = $_POST["description3"]; $InvoiceNum = $_POST["invoicenum"]; $Quantity1 = $_POST["quantity1"]; $Quantity2 = $_POST["quantity2"]; $Quantity3 = $_POST["quantity3"]; $Rate1 = $_POST["rate1"]; $Rate2 = $_POST["rate2"]; $Rate3 = $_POST["rate3"]; $Amount1 = $_POST["amount1"]; $Amount2 = $_POST["amount2"]; $Amount3 = $_POST["amount3"]; $Total = $_POST["total"]; if (empty($BillTo) || empty($Date) || empty($Terms) || empty($Description1) || empty($Description2) || empty($Description3) || echo "<hr/><p>You must enter a value in each field. Click your browser's Back button to return to the invoice.</p><hr />"; else if (!is_numeric($InvoiceNum) || !is_numeric($Quantity1) || !is_numeric($Quantity2) || !is_numeric($Quantity3) || !is_numeric($Rate1) || !is_numeric($Rate2) || !is_numeric($Rate3) || !is_numeric($Amount1) || !is_numeric($Amount2) || !is_numeric($Amount3) || !is_numeric($Total)) echo "<p>You have an error! Please click on your browser's Back button to return to the form.</p>"; else { $InvoiceFile = fopen($InvoiceNum . ".txt", "w") ; echo "<h1>Invoice Saved</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>"; ?> <hr /> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/152334-question-on-debugging/ Share on other sites More sharing options...
Philip Posted April 3, 2009 Share Posted April 3, 2009 You dont close the if: if (empty($BillTo) || empty($Date) || empty($Terms) || empty($Description1) || empty($Description2) || empty($Description3) || echo "<hr/><p>You must enter a value in each field. Click your browser's Back button to return to the invoice.</p><hr />"; //... Also, you don't close your last else statement. Quote Link to comment https://forums.phpfreaks.com/topic/152334-question-on-debugging/#findComment-800048 Share on other sites More sharing options...
geekette Posted April 3, 2009 Author Share Posted April 3, 2009 Thanks for your reply! I closed the If and the last else statement but I'm still receiving the same error. Quote Link to comment https://forums.phpfreaks.com/topic/152334-question-on-debugging/#findComment-800052 Share on other sites More sharing options...
PFMaBiSmAd Posted April 3, 2009 Share Posted April 3, 2009 using terminal to debug is inefficientYou should be developing and debugging code on a local PC that has a web server, php, and if needed mysql. These can be installed individually (for those wanting to learn how), or as a package - http://www.apachefriends.org/en/xampp.html Posting the actual error would help someone to be able to help you. Quote Link to comment https://forums.phpfreaks.com/topic/152334-question-on-debugging/#findComment-800054 Share on other sites More sharing options...
geekette Posted April 3, 2009 Author Share Posted April 3, 2009 I'm using xampp already. Here is the error I received: Parse error: syntax error, unexpected T_ECHO in /Applications/xampp/xamppfiles/htdocs/xampp/classfolder/ch6/SaveInvoice.php on line 37 Quote Link to comment https://forums.phpfreaks.com/topic/152334-question-on-debugging/#findComment-800087 Share on other sites More sharing options...
Philip Posted April 3, 2009 Share Posted April 3, 2009 I'm guessing you still didn't close that first statement correctly. <!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>Save Invoice</title> <link rel="stylesheet" href="php_styles.css" type="text/css" /> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> </head> <body> <?php $BillTo = $_POST["billto"]; $Date = $_POST["date"]; $Terms = $_POST["terms"]; $Description1 = $_POST["description1"]; $Description2 = $_POST["description2"]; $Description3 = $_POST["description3"]; $InvoiceNum = $_POST["invoicenum"]; $Quantity1 = $_POST["quantity1"]; $Quantity2 = $_POST["quantity2"]; $Quantity3 = $_POST["quantity3"]; $Rate1 = $_POST["rate1"]; $Rate2 = $_POST["rate2"]; $Rate3 = $_POST["rate3"]; $Amount1 = $_POST["amount1"]; $Amount2 = $_POST["amount2"]; $Amount3 = $_POST["amount3"]; $Total = $_POST["total"]; if (empty($BillTo) || empty($Date) || empty($Terms) || empty($Description1) || empty($Description2) || empty($Description3)) echo "<hr/><p>You must enter a value in each field. Click your browser's Back button to return to the invoice.</p><hr />"; else if (!is_numeric($InvoiceNum) || !is_numeric($Quantity1) || !is_numeric($Quantity2) || !is_numeric($Quantity3) || !is_numeric($Rate1) || !is_numeric($Rate2) || !is_numeric($Rate3) || !is_numeric($Amount1) || !is_numeric($Amount2) || !is_numeric($Amount3) || !is_numeric($Total)) echo "<p>You have an error! Please click on your browser's Back button to return to the form.</p>"; else { $InvoiceFile = fopen($InvoiceNum . ".txt", "w") ; echo "<h1>Invoice Saved</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>"; } ?> <hr /> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/152334-question-on-debugging/#findComment-800089 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.