Error on line 53, when there was none before.

Discussion in 'HTML & Website Design' started by Matt Ridge, Sep 26, 2011.

  1. #1
    I get the error when running this code:

    Parse error: syntax error, unexpected '<' in /home/pawz/public_html/kaboomlabs.com/PDI/database.php on line 53

    Line 53 on my system is this:

    
    			</div>	
    
    Code (markup):
    The entire code it belongs to is this:

    
    			<div id ="jo">
    			<br />
    				<label>JO:</label><br />
    				<input type="text" name="JO" size="3" value="" />
    			</div>
    
    Code (markup):
    Now I am looking through this code I have no clue why this code is now working that way, I added in some PHP code to put some error messages... but I can't imagine that is the reason why that is not working.

    Can someone help me figure out why this is happening?



    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>PDI Non-Conforming Materials Report</title>
    <link rel="stylesheet" type="text/css" href="pdi.css" />
    </head>
    <body>
    
    
    <div id="logo">
        <img src="images/PDI_Logo_2.1.gif" alt="PDI Logo" />
        
    
    
    </div>
    
    
    <div id="title">    
        <h2>Non-Conforming Materials Report (NCMR)</h2>
    </div>
    <?php
    
    
    if (empty($Added_By){
            echo "You forgot to add who filed the initial report in the Added By field"<br />
            
            
        }
    
    
    ?>
    <form id="all" action ="output.php" method="echo">
        <fieldset>
            <div id ="added">    
                <label>Added By:</label>
                <input type="text" name="Added_By" value="" />
                <label>on:</label>
                <input type="text" name="Added_By_Date" value="" />
            </div>    
            
        <div id="box">    
            <div id ="part">
                <label>Nexx Part:</label>
                <input type="text" name="Nexx_Part" value="" /><br />
                <label>Nexx Rev:</label>
                <input type="text" name="Nexx_Rev" value="" /><br />
                <label>Nexx Part Description:</label>
                <textarea name="Nexx_Part_Description" rows="4" cols="16"></textarea><br />
                <label>NCMR Qty:</label>
                <input type="text" name="NCMR_Qty" value="" />
                <div id ="jo">
                <br />
                    <label>JO:</label><br />
                    <input type="text" name="JO" size="3" value="" />
                </div>    
                <div id ="sn">
                <br />
                    <label>SN:</label><br />
                    <input type="text" name="SN" size="3" value="" />
                </div>    
                <div id ="inv">
                <br />
                    <label>INV:</label><br />
                    <input type="text" name="INV" size="3" value="" />
                </div>    
            </div>
            
            <div id ="manu">
                <label>Nexx Inventory On Hand:</label>
                <input type="text" name="Nexx_Inventory_On_Hand" value="" /><br />
                <label>Nexx Inventory Chk:</label>
                <input type="text" name="Nexx_Inventory_Chk" value="" /><br />
                <label>Supplier Name:</label>
                <textarea name="Supplier_Name" rows="4" cols="16"></textarea><br />
                <label>Supplier Number:</label>
                <input type="text" name="Supplier_Number" value="" /><br />
                <label>Manufacturer Part Number:</label>
                <input type="text" name="Manufacturer_Part_Number" value="" /><br />
                <label>Manufacturer Serial Number: </label>
                <input type="text" name="Manufacturer_Serial_Number" value="" />
                <br />
                <label>NCMR ID:</label>
                <input type="text" name="NCMR_ID" value="" />
            </div>
        </div>
    
    
        <div id="box2">
                <label>Nonconformity: (Be Specific)</label><br />
                <textarea name="Nonconformity" rows="3" cols="85" ></textarea><br />
                <label>Disposition: (Initiator)</label><br />
                <textarea name="Disposition" rows="3" cols="85" ></textarea><br />
                <label>Comments:</label><br />
                <textarea name="Comments" rows="3" cols="85" ></textarea><br />
                <label>Comments and Additional Details:</label><br />
                <textarea name="CommentsAdditional_Details " rows="3" cols="85" ></textarea><br />
                <div id ="po">
                <br />
                    <label>PO:</label><br />
                    <input type="text" name="PO" size="7" value="" />
                </div>    
                <div id ="pod">
                <br />
                    <label>PO Date:</label><br />
                    <input type="text" name="PO_Date" size="7" value="" />
                </div>    
                <div id ="dr">
                <br />
                    <label>Date Recieved:</label><br />
                    <input type="text" name="Date_Recieved" size="7" value="" />
                </div>    
        </div>
                <div id="button">
                <input type="submit" value="Submit NCMR" name="submit" />
                </div>
        </fieldset> 
        
    <div id="xhtml">
        <a href="http://validator.w3.org/check?uri=referer"><img
          src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a>
      </div>    
    </form>
    <?php
    
    
    if (!empty($Added_By){
    //Final code to make sure all fields are entered.
    }
    
    
    ?>
    
    
    
    
    
    
    
    
    </body>
    </html>
    
    
    
    Code (markup):
     
    Matt Ridge, Sep 26, 2011 IP
  2. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #2
    Lines 27-28
    if (empty($Added_By)){
    echo "You forgot to add who filed the initial report in the Added By field<br />";

    Line 129:
    if (!empty($Added_By)){
    //Final code to make sure all fields are entered.
    }
     
    Rukbat, Sep 26, 2011 IP
  3. Matt Ridge

    Matt Ridge Peon

    Messages:
    166
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #3
    Thanks, you know learning from the book is good, as long as they write the code correctly in the first place...

    I still get the error though...

    Lines 27-28
    if (empty($Added_By)[COLOR=#ff0000][U][B])[/B][/U][/COLOR]{
    echo "You forgot to add who filed the initial report in the Added By field[COLOR=#ff0000][U][B]<br />"[/B][/U][/COLOR];
    Code (markup):
    Is this missing a "}"? though?

    That being said, line 50, same error, same place... no reason as far as I can tell.
     
    Last edited: Sep 26, 2011
    Matt Ridge, Sep 26, 2011 IP
  4. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #4
    Post the publisher, to remind me to never buy one of their books. :)

    Code should be copied from a working file and pasted into the manuscript. Even here, not just in books you pay for. Any code I post here that I haven't just run without errors (I ran yours and got your form on my screen before I posted the response) is noted as something like "I haven't run this, but it should work". I'd be embarrassed to have a book out there with my name on it with newbie errors like those.
     
    Rukbat, Sep 26, 2011 IP
  5. Matt Ridge

    Matt Ridge Peon

    Messages:
    166
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #5
    Actually the form is mine with help of people here (the book uses XHTML Transitional, I insisted on strict), the php code they are using is the book's, I copy and pasted their code into my scripts and so far it has been a hit or miss.

    That being said, the error is new, I was using this form Friday without issues... now there is a problem... I am lost in figuring out what is going on. I can't figure out where the problem is, the books don't say, and I can't figure it out. The code itself in the last file looks perfect as far as I can tell for what is required to maintain a strict code.


    As for the books, it's headfirst PHP & SQL



    Here is everything...

    To create the database:

    
    CREATE TABLE ncmrtest (
    Added_By VARCHAR (60),
    Added_By_Date VARCHAR (12),
    Nexx_Part VARCHAR (12),
    Nexx_Rev VARCHAR (12),
    Nexx_Part_Description VARCHAR (100),
    NCMR_Qty VARCHAR (8),
    JO VARCHAR (12),
    SN VARCHAR (12),
    INV VARCHAR (12),
    Nexx_Inventory_On_Hand VARCHAR (8),
    Nexx_Inventory_Chk ARCHAR (12),
    Supplier_Name VARCHAR (50),
    Supplier_Number VARCHAR (18),
    Manufacturer_Part_Number VARCHAR (20),
    Manufacturer_Serial_Number VARCHAR (20),
    NCMR_ID VARCHAR (12),
    Nonconformity VARCHAR (1000),
    Disposition VARCHAR (1000),
    Comments VARCHAR (1000),
    CommentsAdditional_Details VARCHAR (1000),
    PO VARCHAR (12),
    PO_Date VARCHAR (12),
    Date_Received VARCHAR (12)
    );
    Code (markup):
    Here is the

    database.php file:

    <!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" xml:lang="en" lang="en">
    
    
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <title>PDI Non-Conforming Materials Report </title>
    </head>
    
    
    <body>
      <h2>PDI Non-Conforming Materials Report</h2>
    
    
    <?php
      $Added_By = $_POST['Added_By'];
      $Added_By_Date = date('Y-m-d',strtotime($_POST['Added_By_Date']));
      $Nexx_Part = $_POST['Nexx_Part'];
      $Nexx_Rev = $_POST['Nexx_Rev'];
      $Nexx_Part_Description = $_POST['Nexx_Part_Description'];
      $NCMR_Qty = $_POST['NCMR_Qty'];
      $JO = $_POST['JO'];
      $SN = $_POST['SN'];
      $INV = $_POST['INV'];
      $Nexx_Inventory_On_Hand = $_POST['Nexx_Inventory_On_Hand'];
      $Nexx_Inventory_Chk = $_POST['Nexx_Inventory_Chk'];
      $Supplier_Name = $_POST['Supplier_Name'];
      $Supplier_Number = $_POST['Supplier_Number'];
      $Manufacturer_Part_Number = $_POST['Manufacturer_Part_Number'];
      $Manufacturer_Serial_Number = $_POST['Manufacturer_Serial_Number'];
      $NCMR_ID = $_POST['NCMR_ID'];
      $Nonconformity = $_POST['Nonconformity'];
      $Disposition = $_POST['Disposition'];
      $Comments = $_POST['Comments'];
      $CommentsAdditional_Details = $_POST['CommentsAdditional_Details'];
      $PO = $_POST['PO'];
      $PO_Date = date('Y-m-d',strtotime($_POST['PO_Date']));
      $Date_Received = date('Y-m-d',strtotime($_POST['Date_Received']));
    
    
      $dbc = mysqli_connect('localhost', 'pawz_PDI', 'xxxxxxxx', 'pawz_PDI')
        or die('Error connecting to MySQL server.');
    
    
      $query= "INSERT INTO ncmrtest (Added_By, Added_By_Date, Nexx_Part, Nexx_Rev, Nexx_Part_Description, NCMR_Qty, JO, SN, INV, Nexx_Inventory_On_Hand, Nexx_Inventory_Chk, Supplier_Name, Supplier_Number, Manufacturer_Part_Number, Manufacturer_Serial_Number, NCMR_ID, Nonconformity, Disposition, Comments, CommentsAdditional_Details, PO, PO_Date, Date_Received) 
      
      values('$Added_By', '$Added_By_Date', '$Nexx_Part', '$Nexx_Rev', '$Nexx_Part_Description', '$NCMR_Qty', '$JO', '$SN', '$INV', '$Nexx_Inventory_On_Hand', '$Nexx_Inventory_Chk', '$Supplier_Name', '$Supplier_Number', '$Manufacturer_Part_Number', '$Manufacturer_Serial_Number', '$NCMR_ID', '$Nonconformity', '$Disposition', '$Comments', '$CommentsAdditional_Details', '$PO', '$PO_Date', '$Date_Received')"; 
    
    
      if (!$result = mysqli_query($dbc, $query)) 
      {printf("Error message: %s\n", mysqli_error($dbc));
      
      
    }
    
    
      mysqli_close($dbc);
    
    
      echo 'Thanks for submitting the form. The information has been entered and will be reviewed by the correct personnel.';<br />
      ?>
    
    
    </body>
    </html>
    Code (markup):

    Here is the ncmr.html 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>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>PDI Non-Conforming Materials Report</title>
    <link rel="stylesheet" type="text/css" href="pdi.css" />
    </head>
    <body>
    
    
    <div id="logo">
    	<img src="images/PDI_Logo_2.1.gif" alt="PDI Logo" />
    </div>
    
    
    <?php
    if (empty($Added_By)){
    echo 'You forgot to add who filed the initial report in the Added By field<br />';}
    ?>
    
    
    <div id="title">	
    	<h2>Non-Conforming Materials Report (NCMR)</h2>
    </div>
    
    
    <form id="all" action ="output.php" method="echo">
    	<fieldset>
    		<div id ="added">    
    			<label>Added By:</label>
    			<input type="text" name="Added_By" value="" />
    			<label>on:</label>
    			<input type="text" name="Added_By_Date" value="" />
    		</div>	
    		
    	<div id="box">	
    		<div id ="part">
    			<label>Nexx Part:</label>
    			<input type="text" name="Nexx_Part" value="" /><br />
    			<label>Nexx Rev:</label>
    			<input type="text" name="Nexx_Rev" value="" /><br />
    			<label>Nexx Part Description:</label>
    			<textarea name="Nexx_Part_Description" rows="4" cols="16"></textarea><br />
    			<label>NCMR Qty:</label>
    			<input type="text" name="NCMR_Qty" value="" />
    			<div id ="jo">
    			<br />
    				<label>JO:</label><br />
    				<input type="text" name="JO" size="3" value="" />
    			</div>	
    			<div id ="sn">
    			<br />
    				<label>SN:</label><br />
    				<input type="text" name="SN" size="3" value="" />
    			</div>	
    			<div id ="inv">
    			<br />
    				<label>INV:</label><br />
    				<input type="text" name="INV" size="3" value="" />
    			</div>	
    		</div>
    		
    		<div id ="manu">
    			<label>Nexx Inventory On Hand:</label>
    			<input type="text" name="Nexx_Inventory_On_Hand" value="" /><br />
    			<label>Nexx Inventory Chk:</label>
    			<input type="text" name="Nexx_Inventory_Chk" value="" /><br />
    			<label>Supplier Name:</label>
    			<textarea name="Supplier_Name" rows="4" cols="16"></textarea><br />
    			<label>Supplier Number:</label>
    			<input type="text" name="Supplier_Number" value="" /><br />
    			<label>Manufacturer Part Number:</label>
    			<input type="text" name="Manufacturer_Part_Number" value="" /><br />
    			<label>Manufacturer Serial Number: </label>
    			<input type="text" name="Manufacturer_Serial_Number" value="" />
    			<br />
    			<label>NCMR ID:</label>
    			<input type="text" name="NCMR_ID" value="" />
    		</div>
    	</div>
    
    
    	<div id="box2">
    			<label>Nonconformity: (Be Specific)</label><br />
    			<textarea name="Nonconformity" rows="3" cols="85" ></textarea><br />
    			<label>Disposition: (Initiator)</label><br />
    			<textarea name="Disposition" rows="3" cols="85" ></textarea><br />
    			<label>Comments:</label><br />
    			<textarea name="Comments" rows="3" cols="85" ></textarea><br />
    			<label>Comments and Additional Details:</label><br />
    			<textarea name="CommentsAdditional_Details " rows="3" cols="85" ></textarea><br />
    			<div id ="po">
    			<br />
    				<label>PO:</label><br />
    				<input type="text" name="PO" size="7" value="" />
    			</div>	
    			<div id ="pod">
    			<br />
    				<label>PO Date:</label><br />
    				<input type="text" name="PO_Date" size="7" value="" />
    			</div>	
    			<div id ="dr">
    			<br />
    				<label>Date Recieved:</label><br />
    				<input type="text" name="Date_Recieved" size="7" value="" />
    			</div>	
    	</div>
    			<div id="button">
    			<input type="submit" value="Submit NCMR" name="submit" />
    			</div>
    	</fieldset> 
    	
    <div id="xhtml">
        <a href="http://validator.w3.org/check?uri=referer"><img
          src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a>
      </div>	
    </form>
    <?php
    if (!empty($Added_By)){
    //Final code to make sure all fields are entered.
    }
    ?>
    </body>
    </html>
    
    Code (markup):
     
    Matt Ridge, Sep 26, 2011 IP
  6. workingsmart

    workingsmart Well-Known Member

    Messages:
    411
    Likes Received:
    12
    Best Answers:
    9
    Trophy Points:
    120
    #6
    
    if (empty($Added_By){
            echo "You forgot to add who filed the initial report in the Added By field<br />";
        }
    
    Code (markup):
    That's how it should read.
     
    workingsmart, Sep 26, 2011 IP
  7. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #7
    
    if (empty($Added_By){
    ...
    }
    
    PHP:
    is missing the closing paren:

    if (empty($Added_By)){

    If you open 2, you have to close 2.
     
    Rukbat, Sep 26, 2011 IP
  8. workingsmart

    workingsmart Well-Known Member

    Messages:
    411
    Likes Received:
    12
    Best Answers:
    9
    Trophy Points:
    120
    #8
    CORRECTION!!!!!!!!!!!!

    
    if (empty($Added_By)){
            echo "You forgot to add who filed the initial report in the Added By field<br />";
        }
    
    Code (markup):
    Good catch Rukbat....
     
    workingsmart, Sep 26, 2011 IP
  9. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #9
    Only because I do it so often myself. :confused:
     
    Rukbat, Sep 26, 2011 IP
    workingsmart likes this.
  10. workingsmart

    workingsmart Well-Known Member

    Messages:
    411
    Likes Received:
    12
    Best Answers:
    9
    Trophy Points:
    120
    #10
    Me too, which is probably why I didn't see it in the first place.... lol.....


    Where on LI are you?... I'm on LI too... = small world... lol
     
    workingsmart, Sep 26, 2011 IP
  11. Matt Ridge

    Matt Ridge Peon

    Messages:
    166
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #11
    Ok, it took me a while to figure it out, but I have two questions.

    1. When I add that code in, for some reason I get random characters thrown into the web page, how do I get rid of it? ("; } ?>) <---- That is what I see on the page...

    http://www.kaboomlabs.com/PDI/ncmr.html

    2. Minus the typo, is that good practice with what I did, in English, am I accurate in its placements?
     
    Matt Ridge, Sep 26, 2011 IP
  12. workingsmart

    workingsmart Well-Known Member

    Messages:
    411
    Likes Received:
    12
    Best Answers:
    9
    Trophy Points:
    120
    #12
    Your file extension is .html ---> should be .php
     
    workingsmart, Sep 26, 2011 IP