473,387 Members | 3,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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!
Expand|Select|Wrap|Line Numbers
  1. <style type="text/css">
  2.  
  3. BODY    {
  4.     background-image: url("picts/background-sidebar.gif");
  5.     background-repeat: repeat-y;
  6.     background-position: 0px left;
  7.     }
  8.  
  9. </style>
  10.  
  11. <link rel="StyleSheet" href="corporatestyle.css" type="text/css">
  12.  
  13. <script language="JavaScript" type="text/javascript" src="javascripts.js"></script>
  14. <script language="JavaScript" type="text/javascript" src="pop-closeup.js"></script>
  15. <script language="JavaScript" type="text/javascript" src="mouseover.js"></script>
  16.  
  17. </head>
  18.  
  19.   <BODY BGCOLOR="#FFFFFF" TEXT="#000000" leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0" marginheight="0" marginwidth="0">
  20.  
  21.  
  22. <!-- START PAGE TABLE-->
  23.  
  24.   <TABLE cellpadding="0" cellspacing="0" border="0" width="100%" height="100%"><tr><td ALIGN="LEFT" VALIGN="TOP">
  25.  
  26.     <script language="JavaScript" type="text/javascript" src="header.js"></script>
  27.  
  28.  
  29. <!-- START PICTURE TABLE -->
  30.  
  31.     <TABLE cellpadding="0" cellspacing="0" border="0" width="100%" bgcolor="#FFFFFF" class="printhide">
  32.       <tr>
  33.         <td background="picts/Montage.jpg"><a href="index.html">
  34.         <IMG SRC="picts/spacer.gif" border="0" width="700" height="80"></a><br>
  35.         </td>
  36.       </tr>
  37.     </table>
  38.  
  39. <!-- END PICTURE TABLE -->
  40.  
  41.  
  42.     <img src="picts/stretchbar.jpg" width="100%" height="28"><br>
  43.  
  44.     <script language="JavaScript" type="text/javascript" src="menu.js"></script>
  45.  
  46.  
  47. <!-- START CORNER TABLE -->
  48.  
  49.       <TABLE cellpadding="0" cellspacing="0" border="0" width="100%" background="picts/shadow1.gif" class="printhide">
  50.         <tr>
  51.           <td width="227">
  52.           <IMG SRC="picts/corner.gif" height="40" width="227"><br>
  53.           </td>
  54.           <td>
  55.           <IMG SRC="picts/spacer.gif" height="40" width="10" border="0"><br>
  56.           </td>
  57.         </tr>
  58.       </table>
  59.  
  60. <!-- END CORNER TABLE -->
  61.  
  62. <!-- START OUTER TABLE-->
  63.  
  64.         <TABLE cellpadding="0" cellspacing="0" border="0" width="100%">
  65.           <tr>
  66.             <td ALIGN="left" VALIGN="top">
  67.  
  68. <!-- START SPLIT TABLE-->
  69.  
  70.           <TABLE cellpadding="0" cellspacing="0" border="0" width="100%">
  71.             <tr>
  72.               <td ALIGN="LEFT" VALIGN="TOP" width="15">
  73.               <script language="JavaScript" type="text/javascript" src="pageheight.js"></script>
  74.               </td>
  75.               <td ALIGN="LEFT" VALIGN="TOP" width="150">
  76.  
  77. <!-- START SIDEBAR AREA -->
  78.  
  79.               <script language="JavaScript" type="text/javascript" src="sidebar.js"></script>
  80.  
  81.               <br>
  82.               <IMG SRC="picts/spacer.gif" height="5" width="150" border="0"><br>
  83.               </td>
  84.               <td ALIGN="LEFT" VALIGN="TOP" width="30">
  85.               <IMG SRC="picts/spacer.gif" height="400" width="30" border="0"><br>
  86.               </td>
  87.               <td ALIGN="CENTER" VALIGN="TOP">
  88.  
  89. <!-- END SIDEBAR AREA -->
  90.  
  91. <!-- START CONTENT TABLE -->
  92.  
  93.               <TABLE cellpadding="0" cellspacing="0" border="0" width="1000">
  94.                 <tr>
  95.                   <td ALIGN="LEFT" VALIGN="TOP">
  96.                 <tr>
  97.                   <td><span class="title">Test Data ...</span>
  98.                   <p class="copy">
  99.                   <span class="subhead">Structural and Thermal Test Data</span>
  100.                   <br />
  101.                     Acadia products are tested to the highest quality ratings in the industry for residential and multi-family housing.
  102.                   </p>
  103.                   <br />
  104.                   </td>
  105.                   <TABLE cellpadding="0" cellspacing="0" border="0" width="80%">
  106.                     <tr>
  107.                       <td>
  108. <!-- START CHART -->
  109.  
  110. <?php
  111.  
  112.   $conn = @new mysqli('localhost', 'root', 'bonkers1', 'prodtestdata');
  113.  
  114.   if (mysqli_connect_errno() != 0)
  115.   {
  116.     $errno = mysqli_connect_errno();
  117.     $errmsg = mysqli_connect_error();
  118.     echo "Connect Failed with: ($errno) $errmsg<br/>\n";
  119.     exit;
  120.   }
  121.  
  122.   $conn->query("SET NAMES 'utf8'");
  123.  
  124.   // prepare the query 
  125.   $query_str = "SELECT * FROM products";
  126.   $result = @conn->query($query_str);
  127.   if ($result === FALSE)
  128.   {
  129.     $errno = $conn->errno;
  130.     $errmsg = $conn->error;
  131.     echo "Connect Failed with: ($errno) $errmsg<br/>\n";
  132.     $conn->close();
  133.     exit;
  134.   } 
  135.   else
  136.   {
  137.   echo <<<EOM
  138.   <table border="5" bordercolor="darkblue" bordercolorlight="#b2b2ff" cellspacing="0" cellpadding="4">
  139.   <thead>
  140.   <tr>
  141.     <th>Product Name</td>
  142.     <th>Size</td>
  143.     <th>Structural</td>
  144.     <th>Air</td>
  145.     <th>Water</td>
  146.     <th>U-Factor</td>
  147.     <th>SHGC</td>
  148.     <th>VT</td>
  149.     <th>Structural Report</th>
  150.     <th>Thermal Report</th>
  151.   </tr>
  152.   </thead>
  153. EOM;
  154.     // get the data
  155.     while (($row_data = @$result->fetch_assoc()) !==NULL)
  156.     {
  157.     echo <<<EOM     
  158.     <tr>
  159.       <td>{$row_data['prod_name']}</td>
  160.       <td align="center">{$row_data['prod_size']}</td>
  161.       <td align="center">{$row_data['aama_rate']}</td>
  162.       <td align="center">{$row_data['air_rate']}</td>
  163.       <td align="center">{$row_data['water_rate']}</td>
  164.       <td align="center">{$row_data['u_rate']}</td>
  165.       <td align="center">{$row_data['shgc_rate']}</td>
  166.       <td align="center">{$row_data['vt_rate']}</td>
  167.  
  168.     </tr>
  169. EOM;
  170.     }
  171.  
  172.     echo <<<EOTABLE
  173.   </table>
  174.  
  175. EOTABLE;
  176.     //
  177.     // clean up results
  178.     //
  179.     $result->close();
  180.   }
  181.   //
  182.   // clean up connection
  183.   //
  184.   $conn->close();
  185.  
  186. ?>
  187.  
  188.  
  189.  
  190. <!-- END CHART -->
  191.                       </td>
  192.                     </tr>
  193.                   </TABLE>
  194.  
  195. <!-- END CONTENT TABLE -->
  196.  
  197.                   </td>
  198.                 </tr>
  199.               </table>
  200.  
  201. <!-- END SPLIT TABLE -->
  202.  
  203.               </td>
  204.             </tr>
  205.           </table>
  206.  
  207. <!-- END OUTER TABLE-->
  208.             </td>
  209.           </tr>
  210.         </table> 
  211.  
  212. <!-- END PAGE TABLE-->
  213.  
  214.       </td>
  215.     </tr>
  216.     <tr>
  217.     <td VALIGN="BOTTOM">
  218.  
  219. <script language="JavaScript" type="text/javascript" src="menu.js"></script>
  220.  
  221. <img src="picts/stretchbar.jpg" width="100%" height="28"><br>
  222.  
  223.  
  224. <!-- START COPYRIGHT -->
  225.  
  226. <TABLE cellpadding="0" cellspacing="0" border="0" width="100%" background="picts/bottom-shade.gif"><tr><td width="10">
  227. <IMG SRC="picts/spacer.gif" height="45" width="10" border="0" alt="image"><br>
  228. </td><td ALIGN="left" VALIGN="middle">
  229. <script language="JavaScript" type="text/javascript" src="copyright.js"></script>
  230. </td><td ALIGN="right" VALIGN="middle">
  231. </TD><td width="10">
  232. <IMG SRC="picts/spacer.gif" height="10" width="10" border="0" alt="image"><br>
  233. </td></tr></table>
  234.  
  235. <!-- END COPYRIGHT -->
  236.  
  237.       </td>
  238.     </tr>
  239.   </table>
  240.  
  241. </BODY>
  242. </HTML>
  243.  
Thank You,
Ann
Nov 21 '10 #1

✓ answered by Dormilich

you have to name the file with the .php extension otherwise the PHP interpreter doesnt work on it.

4 2925
Dormilich
8,658 Expert Mod 8TB
you have to name the file with the .php extension otherwise the PHP interpreter doesnt work on it.
Nov 21 '10 #2
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...
Nov 21 '10 #3
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.
Expand|Select|Wrap|Line Numbers
  1. </head>
  2.  
  3. <body bgcolor="#FFFFFF" text="#000000" leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0" marginheight="0" marginwidth="0">
  4.  
  5. <?php
  6.  
  7.   $conn = @new mysqli('localhost', 'root', 'bonkers1', 'prodtestdata');
  8.  
  9.   if (mysqli_connect_errno() != 0)
  10.   {
  11.     $errno = mysqli_connect_errno();
  12.     $errmsg = mysqli_connect_error();
  13.     echo "Connect Failed with: ($errno) $errmsg<br/>\n";
  14.     exit;
  15.   }
  16.  
  17.   // prepare the query 
  18.   $query_str = "SELECT * FROM products";
  19.   $result = mysqli_query($query_str);
  20.  
  21. ?>
  22.  
  23. <!-- START PAGE TABLE-->
  24.  
  25.   <table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
  26.     <tr>
  27.       <td align="left" valign="top">
  28.       <script language="JavaScript" type="text/javascript" src="header.js"></script>
  29.  
  30.  
  31. <!-- START PICTURE TABLE -->
  32.  
  33.     <table cellpadding="0" cellspacing="0" border="0" width="100%" bgcolor="#FFFFFF" class="printhide">
  34.       <tr>
  35.         <td background="picts/Montage.jpg"><a href="index.html">
  36.         <img src="picts/spacer.gif" border="0" width="700" height="80"/></a><br>
  37.         </td>
  38.       </tr>
  39.     </table>
  40.  
  41. <!-- END PICTURE TABLE -->
  42.  
  43.  
  44.     <img src="picts/stretchbar.jpg" width="100%" height="28"/><br>
  45.  
  46.     <script language="JavaScript" type="text/javascript" src="menu.js"></script>
  47.  
  48.  
  49. <!-- START CORNER TABLE -->
  50.  
  51.       <table cellpadding="0" cellspacing="0" border="0" width="100%" background="picts/shadow1.gif" class="printhide">
  52.         <tr>
  53.           <td width="227">
  54.           <img src="picts/corner.gif" height="40" width="227"/><br>
  55.           </td>
  56.           <td>
  57.           <img src="picts/spacer.gif" height="40" width="10" border="0"/><br>
  58.           </td>
  59.         </tr>
  60.       </table>
  61.  
  62. <!-- END CORNER TABLE -->
  63.  
  64. <!-- START OUTER TABLE-->
  65.  
  66.         <table cellpadding="0" cellspacing="0" border="0" width="100%">
  67.           <tr>
  68.             <td align="left" valign="top">
  69.  
  70. <!-- START SPLIT TABLE-->
  71.  
  72.           <table cellpadding="0" cellspacing="0" border="0" width="100%">
  73.             <tr>
  74.               <td align="left" valign="top" width="15">
  75.               <script language="JavaScript" type="text/javascript" src="pageheight.js"></script>
  76.               </td>
  77.               <td align="left" valign="top" width="150">
  78.  
  79. <!-- START SIDEBAR AREA -->
  80.  
  81.               <script language="JavaScript" type="text/javascript" src="sidebar.js"></script>
  82.               <br>
  83.               <img src="picts/spacer.gif" height="5" width="150" border="0"/><br>
  84.               </td>
  85.               <td align="left" valign="top" width="30">
  86.               <img src="picts/spacer.gif" height="400" width="30" border="0"/><br>
  87.               </td>
  88.               <td align="center" valign="top">
  89.  
  90. <!-- END SIDEBAR AREA -->
  91.  
  92. <!-- START CONTENT TABLE -->
  93.  
  94.               <table cellpadding="0" cellspacing="0" border="0" width="1000">
  95.                 <tr align="left" valign="top">
  96.                   <td><span class="title">Test Data ...</span>
  97.                   <p class="copy">
  98.                   <span class="subhead">Structural and Thermal Test Data</span>
  99.                   <br />
  100.                     Acadia products are tested to the highest quality ratings in the industry for residential and multi-family housing.
  101.                   </p>
  102.                   <br />
  103.                   </td>
  104.                 </tr>
  105.  
  106. <!-- START CHART -->
  107.  
  108.                   <table border="5" bordercolor="blue" bordercolorlight="#b2b2ff" cellspacing="0" cellpadding="4">
  109.                     <thead>
  110.                       <tr>
  111.                       <th>Product Name</td>
  112.                       <th>Size</td>
  113.                       <th>Structural</td>
  114.                       <th>Air</td>
  115.                       <th>Water</td>
  116.                       <th>U-Factor</td>
  117.                       <th>SHGC</td>
  118.                       <th>VT</td>
  119.                       <th>Structural Report</th>
  120.                       <th>Thermal Report</th>
  121.                       </tr>
  122.                     </thead>
  123. <?php
  124.  
  125.     while (($row_data = mysqli_fetch_assoc($result)) !==NULL)
  126.  
  127.     <tr>
  128.       <td>{$row_data['prod_name']}</td>
  129.       <td align="center">{$row_data['prod_size']}</td>
  130.       <td align="center">{$row_data['aama_rate']}</td>
  131.       <td align="center">{$row_data['air_rate']}</td>
  132.       <td align="center">{$row_data['water_rate']}</td>
  133.       <td align="center">{$row_data['u_rate']}</td>
  134.       <td align="center">{$row_data['shgc_rate']}</td>
  135.       <td align="center">{$row_data['vt_rate']}</td>
  136.       <td align="left"><a href="testreports/200singlehung.pdf" target="window">200 Sinlge Hung</a></td>
  137.     </tr>
  138.  
  139.   </table>
  140.  
  141.     $result->close();
  142.  
  143.     $conn->close();
  144.  
  145. ?>
  146.  
  147. <!-- END CONTENT TABLE -->
  148.  
  149.               </table>
  150.  
  151. <!-- END SPLIT TABLE -->
  152.  
  153.               </td>
  154.             </tr>
  155.           </table>
  156.  
  157. <!-- END OUTER TABLE-->
  158.             </td>
  159.           </tr>
  160.         </table>
  161.  
Any thoughts would be greatly appreciated. Thank You
Nov 22 '10 #4
Dormilich
8,658 Expert Mod 8TB
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.
Nov 22 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Stupidgirl | last post by:
Hi, i have had no problem displaying the current date and time, on a static webpage. However, when i try to use the various PHP and MySQL snippets, it does'nt seem to work out. My success story...
2
by: Steve at Pixelda | last post by:
I accidentally put this on another group - this is the more likley home... The first code fragment creates the simplest of XML Schemas is code. After the “Compile()” method is called on the...
4
by: Carlo Marchesoni | last post by:
I have a button that opens a new Window (some kind of search-window), which is fired using JavaScript (btnSearch.Attributes=".....";) Now I need to run some code behind code BEFORE this JavaScript...
1
by: Asha | last post by:
greetings, i want to populate a datagrid with data from the db and this requires a post back and code behind do its job. after the datagrid is being populated, i want the client side to execute...
1
by: bennett | last post by:
At http://www.brainjammer.com/testing/validator_test.aspx I have a text field where you can enter text, and a button where if you click the button, it sets the value of a label below it, to...
8
by: neilmcguigan | last post by:
I just wanted to list some reasons why I prefer inline code to code-behind. 1. you can fix some bugs more quickly. remote desktop into server, change the aspx file, and she's good to go. I'd say...
1
by: ujwala | last post by:
I am trying to develop a tool which requires the source(html) code of the web page i open in the browser.so is there any way to get the html source code of the web page as soon as i open it and store...
1
by: John Dalberg | last post by:
I have tens of aspx files which contain server side code. I need to move the code to code behind files. Is there a tool that can automate this? John Dalberg
1
by: emekadavid | last post by:
i've searched if this has been answered but can't find an answer only found something on obfuscation. my problem: i have a code that opens a new window, a blank window, but on clicking the x button...
6
by: mott3510 | last post by:
I wrote a python script and when I run it, it outputs what I want, so I know that it is working. Now I want to be able to put the output of the code on my website and I have no idea how to do this,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.