PHP代码显示为文本

时间:2010-12-07 15:59:41

标签: php html

我确信我的代码是正确的,在您说文件被称为whatever.html之前我肯定它是.php 它显示我的所有代码,而不是从特定点开始,哦,顺便说一下PHP在我的其他页面上工作。所以安装了PHP 这是我的代码:

    <?
include("include/session.php");
  $ASID  = $_GET['id'];
  $BOATNAME  = $_GET['moorings'];
 $LoginName = 'Log in';
 if($session->logged_in){
 $LoginName = 'Account Center';
 }
 $con = mysql_connect("********","******","*************2");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  mysql_select_db("****", $con);
$query = "select * from **** where **** like '$ASID' AND BoatName like '$BOATNAME'";
$result = mysql_query($query) or die("Couldn't execute query");
while ($row= mysql_fetch_array($result)) {
  $MooringList = $row["MooringList"];
  $MooringList2 = $row["MooringList2"];
  $Number = $row["Number"];
  $Latitude = $row["Latitude"];
  $Latitude2 = $row["Latitude2"];
  $Latitude3 = $row["Latitude3"];
  $Longitude = $row["Longitude"];
  $Longitude2 = $row["Longitude2"];
  $Longitude3 = $row["Longitude3"];
  $Schedule = $row["Schedule"];
  $ScheduleCD = $row["ScheduleCD"];
  $MoorLengthFT = $row["MoorLengthFT"];
  $MoorLengthMtrs = $row["MoorLengthMTRS"];
  $MoorTonnage = $row["MoorTonnage"];
  $Layer = $row["Layer"];
  $BoatName = $row["BoatName"];
  $BoatType = $row["BoatType"];
  $BoatLengthFT = $row["BoatLengthFT"];
  $BoatLengthMTRS = $row["BoatLengthMTRS"];
  $BoatInsurance = $row["BoatInsurance"];  
}  
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>**** - Add Mooring</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="js/jquery-1.3.2.js" type="text/javascript"></script>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
        $("#myform").validate({
            debug: false,
            rules: {
                     Number:"required"                  
            },
            messages: { 
                  Number:"* The number can't be blank"  
            },
            submitHandler: function(form) {
                // do other stuff for a valid form
                $.post('addMooringScript.php', $("#myform").serialize(), function(data) {       
                    $('#result').html(data);
                });
            }
        });
    });
    </script>
    <style>
    label.error { width: 250px; display: inline; color: red;}
    </style>
</head>
<body>
<div id="header">
<h1>******</h1>
<div id="loginDetails">
<? include('loggedInTopStatus.php'); ?>
</div>
</div>
<div class="content"><br />
<div id="news">
<div id="right">
<form name="myform" id="myform" action="" method="POST">  
<h2>Moorings - Add</h2>
<div id="result"></div>
<table width = "2000" border="0">
<tr width="1000">
<input type="hidden" name="AssignedTo" value ="<? $_POST['id'] ?> "/>
<tr>
<td width="50px">Mooring List: </td>
<td>
 <input type="text" name="MooringList" size="5" value="<? echo $MooringList; ?>" />
  <input type="text" name="MooringList2" size="20" value="<? echo $MooringList2; ?>" />
</tr></td>
<tr><td width="50px">Number: </td><td><input type="text" name="Number" maxlength="30" value="<? echo $Number ?>"></td></td>
<tr><td width="50px">Latitude: </td><td>
  <input type="text" name="Latitude" size="3" value="<? echo $Latitude; ?>" />O
  <input type="text" name="Latitude2" size="3" value="<? echo $Latitude2; ?>" />' .
  <input type="text" name="Latitude3" size="5" value="<? echo $Latitude3; ?>" />
</tr></td>
<tr><td width="50px">Longitude: </td><td>
  <input type="text" name="Longitude" size="3" value="<? echo $Longitude; ?>" />O
  <input type="text" name="Longitude2" size="3" value="<? echo $Longitude2; ?>" />' .
  <input type="text" name="Longitude3" size="5" value="<? echo $Longitude3; ?>" />
</tr></td>
<tr><td width="50px">Schedule: </td><td>
<input type="text" name="Schedule" size="3" /> CD 
  <input type="text" name="ScheduleMtrs" size="3" /> Mtrs
</tr></td>
<tr><td width="50px">Moor Length: </td><td>
  <input type="text" name="Moorlength" size="3" /> FT 
  <input type="text" name="MoorlengthMtrs" size="3" /> Mtrs
</tr></td>
 <tr><td width="50px">Moor Tonnage: </td><td>
  <input type="text" name="MoorTonnage" size="4" /> 
</tr></td>
 <tr><td width="50px">Layer: </td><td>
   <input type="text" name="Layer" size="8" /> 
</tr></td>
 <tr><td width="50px">Boat Name: </td><td>
   <input type="text" name="BoatName" size="15" />
   <input type="radio" name="BoatType" value="Leisure" /><b> Leisure  </b>
</tr></td>
     <tr><td width="50px">Type: </td><td>
   <input type="text" name="Type" size="15" />
   <input type="radio" name="BoatType" value="Commercial" /> <b>Commercial  </b>
</tr></td>
     <tr><td width="50px">Length: </td><td>
   <input type="text" name="LengthFt" size="8" />Ft
   <input type="text" name="LengthMtrs" size="8" />Mtrs   
</tr></td>
     <tr><td width="50px">Insurance: </td><td>
   <input type="text" name="Insurance" size="18" />
</tr></td>
</tr>
<input type="hidden" name="id" value="<? echo $_GET['id']; ?>" />
<tr><td><input type="submit" value="Edit Mooring" />   </tr></td>
</table>
</form>
</div>
<div class="left">
<? include('sitemenu.php'); ?>
</div>
<br />

<div id="footer">
<a href="#">&copy; 2010 *****</a>
</div>
</div>
</div>
</body>
</html>

另外,我已将其过滤到了nessasary

4 个答案:

答案 0 :(得分:3)

您已在php.ini中禁用了short_open_tags,对吗?然后,您必须使用<?php启动PHP代码块,而不仅仅是<?

答案 1 :(得分:0)

在开头使用<?php

答案 2 :(得分:0)

可能禁用了短标签。尝试使用<?php而不是<?

答案 3 :(得分:0)

对回复一篇非常古老的帖子感到抱歉,但我遇到了完全相同的问题,所以我的解决方案可以帮助某人。

就我而言,这是一个ID-ten-T问题。

我在两个相同名称的文件夹中插入了两个插入代码的副本(我已经设置了'inserts'文件夹,复制了文件但未能删除所有原件。所以代码包括原始文件但是我正在编辑副本。原来没有

ID-ten-T,对于那些之前没有遇到过的人,有时写成ID10T