code shows up as code on webpage instead of executing...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ann Madden
    New Member
    • Nov 2010
    • 6

    code shows up as code on webpage instead of executing...

    Hello - super green here again. I am creating a web page for work (also my school project) and the php code is working fine on its own... when I add it to the html code, it shows up on the web page as code instead of building the chart like it does by itself. I have been working on this for days, trying all kinds of different configurations, but nothing has worked so far. A good portion of th code is below. Any insights on how I screwed this up would be great!
    Code:
    <style type="text/css">
    
    BODY	{
    	background-image: url("picts/background-sidebar.gif");
    	background-repeat: repeat-y;
    	background-position: 0px left;
    	}
    
    </style>
    
    <link rel="StyleSheet" href="corporatestyle.css" type="text/css">
    
    <script language="JavaScript" type="text/javascript" src="javascripts.js"></script>
    <script language="JavaScript" type="text/javascript" src="pop-closeup.js"></script>
    <script language="JavaScript" type="text/javascript" src="mouseover.js"></script>
    
    </head>
    
      <BODY BGCOLOR="#FFFFFF" TEXT="#000000" leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0" marginheight="0" marginwidth="0">
    
    
    <!-- START PAGE TABLE-->
    
      <TABLE cellpadding="0" cellspacing="0" border="0" width="100%" height="100%"><tr><td ALIGN="LEFT" VALIGN="TOP">
    
        <script language="JavaScript" type="text/javascript" src="header.js"></script>
    
    
    <!-- START PICTURE TABLE -->
    
        <TABLE cellpadding="0" cellspacing="0" border="0" width="100%" bgcolor="#FFFFFF" class="printhide">
          <tr>
            <td background="picts/Montage.jpg"><a href="index.html">
            <IMG SRC="picts/spacer.gif" border="0" width="700" height="80"></a><br>
            </td>
          </tr>
        </table>
    
    <!-- END PICTURE TABLE -->
    
    
        <img src="picts/stretchbar.jpg" width="100%" height="28"><br>
    
        <script language="JavaScript" type="text/javascript" src="menu.js"></script>
    
    
    <!-- START CORNER TABLE -->
    
          <TABLE cellpadding="0" cellspacing="0" border="0" width="100%" background="picts/shadow1.gif" class="printhide">
            <tr>
              <td width="227">
              <IMG SRC="picts/corner.gif" height="40" width="227"><br>
              </td>
              <td>
              <IMG SRC="picts/spacer.gif" height="40" width="10" border="0"><br>
              </td>
            </tr>
          </table>
    
    <!-- END CORNER TABLE -->
    
    <!-- START OUTER TABLE-->
    
            <TABLE cellpadding="0" cellspacing="0" border="0" width="100%">
              <tr>
                <td ALIGN="left" VALIGN="top">
    
    <!-- START SPLIT TABLE-->
    
              <TABLE cellpadding="0" cellspacing="0" border="0" width="100%">
                <tr>
                  <td ALIGN="LEFT" VALIGN="TOP" width="15">
                  <script language="JavaScript" type="text/javascript" src="pageheight.js"></script>
                  </td>
                  <td ALIGN="LEFT" VALIGN="TOP" width="150">
    
    <!-- START SIDEBAR AREA -->
    
                  <script language="JavaScript" type="text/javascript" src="sidebar.js"></script>
    
                  <br>
                  <IMG SRC="picts/spacer.gif" height="5" width="150" border="0"><br>
                  </td>
                  <td ALIGN="LEFT" VALIGN="TOP" width="30">
                  <IMG SRC="picts/spacer.gif" height="400" width="30" border="0"><br>
                  </td>
                  <td ALIGN="CENTER" VALIGN="TOP">
    
    <!-- END SIDEBAR AREA -->
    
    <!-- START CONTENT TABLE -->
    
                  <TABLE cellpadding="0" cellspacing="0" border="0" width="1000">
                    <tr>
                      <td ALIGN="LEFT" VALIGN="TOP">
                    <tr>
                      <td><span class="title">Test Data ...</span>
                      <p class="copy">
                      <span class="subhead">Structural and Thermal Test Data</span>
                      <br />
                        Acadia products are tested to the highest quality ratings in the industry for residential and multi-family housing.
                      </p>
                      <br />
                      </td>
                      <TABLE cellpadding="0" cellspacing="0" border="0" width="80%">
                        <tr>
                          <td>
    <!-- START CHART -->
    
    <?php
    
      $conn = @new mysqli('localhost', 'root', 'bonkers1', 'prodtestdata');
    
      if (mysqli_connect_errno() != 0)
      {
        $errno = mysqli_connect_errno();
        $errmsg = mysqli_connect_error();
        echo "Connect Failed with: ($errno) $errmsg<br/>\n";
        exit;
      }
    
      $conn->query("SET NAMES 'utf8'");
    
      // prepare the query 
      $query_str = "SELECT * FROM products";
      $result = @conn->query($query_str);
      if ($result === FALSE)
      {
        $errno = $conn->errno;
        $errmsg = $conn->error;
        echo "Connect Failed with: ($errno) $errmsg<br/>\n";
        $conn->close();
        exit;
      } 
      else
      {
      echo <<<EOM
      <table border="5" bordercolor="darkblue" bordercolorlight="#b2b2ff" cellspacing="0" cellpadding="4">
      <thead>
      <tr>
        <th>Product Name</td>
        <th>Size</td>
        <th>Structural</td>
        <th>Air</td>
        <th>Water</td>
        <th>U-Factor</td>
        <th>SHGC</td>
        <th>VT</td>
        <th>Structural Report</th>
        <th>Thermal Report</th>
      </tr>
      </thead>
    EOM;
        // get the data
        while (($row_data = @$result->fetch_assoc()) !==NULL)
        {
        echo <<<EOM     
        <tr>
          <td>{$row_data['prod_name']}</td>
          <td align="center">{$row_data['prod_size']}</td>
          <td align="center">{$row_data['aama_rate']}</td>
          <td align="center">{$row_data['air_rate']}</td>
          <td align="center">{$row_data['water_rate']}</td>
          <td align="center">{$row_data['u_rate']}</td>
          <td align="center">{$row_data['shgc_rate']}</td>
          <td align="center">{$row_data['vt_rate']}</td>
          
        </tr>
    EOM;
        }
    
        echo <<<EOTABLE
      </table>
    
    EOTABLE;
        //
        // clean up results
        //
        $result->close();
      }
      //
      // clean up connection
      //
      $conn->close();
    
    ?>
                        
    
    
    <!-- END CHART -->
                          </td>
                        </tr>
                      </TABLE>
    
    <!-- END CONTENT TABLE -->
    
                      </td>
                    </tr>
                  </table>
    
    <!-- END SPLIT TABLE -->
    
                  </td>
                </tr>
              </table>
    
    <!-- END OUTER TABLE-->
                </td>
              </tr>
            </table> 
    
    <!-- END PAGE TABLE-->
    
          </td>
        </tr>
        <tr>
        <td VALIGN="BOTTOM">
    
    <script language="JavaScript" type="text/javascript" src="menu.js"></script>
    
    <img src="picts/stretchbar.jpg" width="100%" height="28"><br>
    
    
    <!-- START COPYRIGHT -->
    
    <TABLE cellpadding="0" cellspacing="0" border="0" width="100%" background="picts/bottom-shade.gif"><tr><td width="10">
    <IMG SRC="picts/spacer.gif" height="45" width="10" border="0" alt="image"><br>
    </td><td ALIGN="left" VALIGN="middle">
    <script language="JavaScript" type="text/javascript" src="copyright.js"></script>
    </td><td ALIGN="right" VALIGN="middle">
    </TD><td width="10">
    <IMG SRC="picts/spacer.gif" height="10" width="10" border="0" alt="image"><br>
    </td></tr></table>
    
    <!-- END COPYRIGHT -->
    
          </td>
        </tr>
      </table>
    
    </BODY>
    </HTML>
    Thank You,
    Ann
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    you have to name the file with the .php extension otherwise the PHP interpreter doesn’t work on it.

    Comment

    • Ann Madden
      New Member
      • Nov 2010
      • 6

      #3
      So instead of putting the code itself into the .html file, I am suppose to load the .php file with the same code instead?

      I will try that - thanks...

      Comment

      • Ann Madden
        New Member
        • Nov 2010
        • 6

        #4
        Still not working - any thoughts...

        okay - tried that - maybe I am not doing it right, but that did not work either. When I open chart.php in localhost - it works fine. When I turn chart.php into an html file, it then just shows the code. I am missing an important step here - I just don't know what it is. I have changed the code a bit which has cleaned up most of the written code displayed on the page, except under each heading of the table it displays the variable instead of the data, and then.. $result->close(); $conn->close(); ?> .. shows up directly under the table.
        Code:
        </head>
        
        <body bgcolor="#FFFFFF" text="#000000" leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0" marginheight="0" marginwidth="0">
        
        <?php
        
          $conn = @new mysqli('localhost', 'root', 'bonkers1', 'prodtestdata');
        
          if (mysqli_connect_errno() != 0)
          {
            $errno = mysqli_connect_errno();
            $errmsg = mysqli_connect_error();
            echo "Connect Failed with: ($errno) $errmsg<br/>\n";
            exit;
          }
        
          // prepare the query 
          $query_str = "SELECT * FROM products";
          $result = mysqli_query($query_str);
        
        ?>
        
        <!-- START PAGE TABLE-->
        
          <table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
            <tr>
              <td align="left" valign="top">
              <script language="JavaScript" type="text/javascript" src="header.js"></script>
        
        
        <!-- START PICTURE TABLE -->
        
            <table cellpadding="0" cellspacing="0" border="0" width="100%" bgcolor="#FFFFFF" class="printhide">
              <tr>
                <td background="picts/Montage.jpg"><a href="index.html">
                <img src="picts/spacer.gif" border="0" width="700" height="80"/></a><br>
                </td>
              </tr>
            </table>
        
        <!-- END PICTURE TABLE -->
        
        
            <img src="picts/stretchbar.jpg" width="100%" height="28"/><br>
        
            <script language="JavaScript" type="text/javascript" src="menu.js"></script>
        
        
        <!-- START CORNER TABLE -->
        
              <table cellpadding="0" cellspacing="0" border="0" width="100%" background="picts/shadow1.gif" class="printhide">
                <tr>
                  <td width="227">
                  <img src="picts/corner.gif" height="40" width="227"/><br>
                  </td>
                  <td>
                  <img src="picts/spacer.gif" height="40" width="10" border="0"/><br>
                  </td>
                </tr>
              </table>
        
        <!-- END CORNER TABLE -->
        
        <!-- START OUTER TABLE-->
        
                <table cellpadding="0" cellspacing="0" border="0" width="100%">
                  <tr>
                    <td align="left" valign="top">
        
        <!-- START SPLIT TABLE-->
        
                  <table cellpadding="0" cellspacing="0" border="0" width="100%">
                    <tr>
                      <td align="left" valign="top" width="15">
                      <script language="JavaScript" type="text/javascript" src="pageheight.js"></script>
                      </td>
                      <td align="left" valign="top" width="150">
        
        <!-- START SIDEBAR AREA -->
        
                      <script language="JavaScript" type="text/javascript" src="sidebar.js"></script>
                      <br>
                      <img src="picts/spacer.gif" height="5" width="150" border="0"/><br>
                      </td>
                      <td align="left" valign="top" width="30">
                      <img src="picts/spacer.gif" height="400" width="30" border="0"/><br>
                      </td>
                      <td align="center" valign="top">
        
        <!-- END SIDEBAR AREA -->
        
        <!-- START CONTENT TABLE -->
        
                      <table cellpadding="0" cellspacing="0" border="0" width="1000">
                        <tr align="left" valign="top">
                          <td><span class="title">Test Data ...</span>
                          <p class="copy">
                          <span class="subhead">Structural and Thermal Test Data</span>
                          <br />
                            Acadia products are tested to the highest quality ratings in the industry for residential and multi-family housing.
                          </p>
                          <br />
                          </td>
                        </tr>
        
        <!-- START CHART -->
        
                          <table border="5" bordercolor="blue" bordercolorlight="#b2b2ff" cellspacing="0" cellpadding="4">
                            <thead>
                              <tr>
                              <th>Product Name</td>
                              <th>Size</td>
                              <th>Structural</td>
                              <th>Air</td>
                              <th>Water</td>
                              <th>U-Factor</td>
                              <th>SHGC</td>
                              <th>VT</td>
                              <th>Structural Report</th>
                              <th>Thermal Report</th>
                              </tr>
                            </thead>
        <?php
        
            while (($row_data = mysqli_fetch_assoc($result)) !==NULL)
        
            <tr>
              <td>{$row_data['prod_name']}</td>
              <td align="center">{$row_data['prod_size']}</td>
              <td align="center">{$row_data['aama_rate']}</td>
              <td align="center">{$row_data['air_rate']}</td>
              <td align="center">{$row_data['water_rate']}</td>
              <td align="center">{$row_data['u_rate']}</td>
              <td align="center">{$row_data['shgc_rate']}</td>
              <td align="center">{$row_data['vt_rate']}</td>
              <td align="left"><a href="testreports/200singlehung.pdf" target="window">200 Sinlge Hung</a></td>
            </tr>
        
          </table>
           
            $result->close();
        
            $conn->close();
        
        ?>
            
        <!-- END CONTENT TABLE -->
        
                      </table>
        
        <!-- END SPLIT TABLE -->
        
                      </td>
                    </tr>
                  </table>
        
        <!-- END OUTER TABLE-->
                    </td>
                  </tr>
                </table>
        Any thoughts would be greatly appreciated. Thank You

        Comment

        • Dormilich
          Recognized Expert Expert
          • Aug 2008
          • 8694

          #5
          okay - tried that - maybe I am not doing it right, but that did not work either. When I open chart.php in localhost - it works fine. When I turn chart.php into an html file, it then just shows the code.
          .html files are not recognised by the PHP interpreter, thus any PHP code in them will show as such.

          Comment

          Working...