I am getting a error of:
Parse error: syntax error, unexpected T_STRING in /home/mprhode/public_html/lightbulb.php on line 1

I can't seem to find out the problem. Please direct me?

<?xml version = "1.0"  encoding = "utf-8" ?>
<!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> Assignment 3 - 9.11 php  </title>
  </head>
  <body>
<?php

// Get form data values

      $fourw = $_POST["fourw"];
      $eightw = $_POST["eightw"];
      $fourlong = $_POST["fourlong"];
      $eightlong = $_POST["eightlong"];
      $name = $_POST["name"];
      $payment = $_POST["payment"];

// If any of the quantities are blank, set them to zero

      if ($fourw == "") $fourw = 0;
      if ($eightw == "") $eightw = 0;
      if ($fourlong == "") $fourlong = 0;
      if ($eightlong == "") $eightlong = 0;

// Compute the item costs and total cost

      $fourw_cost = 2.39 * $fourw;
      $eightw_cost = 4.29 * $eightw;
      $fourlong_cost = 3.95 * $fourlong;
      $eightlong_cost = 7.49 * $eightlong;
      $total_price = $fourw_cost + $eightw_cost + 
                     $fourlong_cost + $eightlong_cost;
	  $with_tax = 1.062 * $total_price;
      $total_items = $fourw + $eightw + $fourlong + $eightlong;

// Return the results to the browser in a table

    ?>
    <h4> Customer: </h4>
    <?php
      print ("$name <br />");
    ?>
    <p />

    <table border = "border">
      <caption> Order Information </caption>
      <tr>
        <th> Product </th>
        <th> Unit Price </th>
        <th> Quantity Ordered </th>
        <th> Item Cost </th>
      </tr>
      <tr align = "center">
        <td> 100 watt light bulb (4 pk)  </td>
        <td> $2.39 </td>
        <td> <?php print ("$fourw"); ?> </td>
        <td> <?php printf ("$ %4.2f", $fourw_cost); ?>
        </td>
      </tr>
      <tr align = "center">
        <td>100 watt light bulb (8 pk)</td>
        <td> $4.29 </td>
        <td> <?php print ("$eightw"); ?> </td>
        <td> <?php printf ("$ %4.2f", $eightw_cost); ?>
        </td>
        </tr>
      <tr align = "center">
        <td>100 watt long-life light bulb (4 pk)</td>
        <td> $3.95 </td>
        <td> <?php print ("$fourlong"); ?> </td>
        <td> <?php printf ("$ %4.2f", $fourlong_cost); ?>
        </td>
      </tr>
      <tr align = "center">
        <td>100 watt long-life light bulb (8 pk)</td>
        <td> $7.49 </td>
        <td> <?php print ("$eightlong"); ?> </td>
        <td> <?php printf ("$ %4.2f", $eightlong_cost); ?>
        </td>
      </tr>
    </table>
    <p /> <p />

    <?php
      print ("You ordered $total_items lightbulbs items <br />");
      printf ("Your total bill with 6.2% sales tax is: $ %5.2f <br />", $with_tax);
      print ("Your chosen method of payment is: $payment <br />");
    ?>
  </body>
</html>

I suspect it's that the setting "short_open_tag" is forced on, and so the first two characters of line 1 (the less-than symbol followed by the question mark) is causing PHP to start interpreting what is after that, which happens to be the contents of the XML header tag and not PHP code.

You can always verify whether short_open_tag is the problem by looking at phpinfo(). Simply create a PHP file with only the following content:

<?php phpinfo(); ?>

If php_open_tag is set to "On" then that is your problem.

The only way to disable this is to use .htaccess (provided your hosting company allows you to). You would need to add the following line into the .htaccess file:

short_open_tag on

If you are not sure whether .htaccess directives are allowed for you, you can always try it, and then check again using phpinfo() as above.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.