2012-02-16 38 views
0

我在Dreamweaver中有一些HTML/PHP代码,对于我的生活我无法弄清楚这个错误的原因。该错误读取,“行318上有语法错误。代码提示可能无法正常工作,直到您解决此错误。”有人可以帮忙吗?是的,我知道我有可怕的评论练习和可变的命名法。该代码也可以发现here在代码中查找语法错误[PHP/HTML]

<?php 
require $_SERVER['DOCUMENT_ROOT'].'/resources/feeds.php'; 
require $_SERVER['DOCUMENT_ROOT'].'/resources/mysql.php'; 
session_start(); 
if(empty($_SESSION['username']) || $_SESSION['login'] != 'true'){ header("location:/"); } 
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<!-- 
Design by Free CSS Templates 
http://www.freecsstemplates.org 
Released for free under a Creative Commons Attribution 2.5 License 

Name  : Vegetables 
Description: A two-column, fixed-width design with dark color scheme. 
Version : 1.0 
Released : 20110416 

--> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<link rel="icon" type="/image/png" href="/resources/favicon.png"> 
<meta name="keywords" content="" /> 
<meta name="description" content="" /> 
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
<title>My Website • Edit Information</title> 
<link href="/style.css" rel="stylesheet" type="text/css" media="screen" /> 
</head> 
<body> 
<div id="header"> 
    <div id="logo"> 
     <h1><a href="/">My Website</a></h1> 
     <a href="/">This is the best website ever</a> 
     <p>&nbsp;</p> 
</div> 
</div> 
<!-- end #header --> 
<div id="wrapper"> 
    <div id="menu"> 
     <ul> 
      <li class="current_page_item"><a href="/">Home</a></li> 
      <li><a href="/events">Events</a></li> 
      <li><a href="/forum">Forums</a></li> 
      <li><a href="/about">About</a></li> 
      <li><a href="/minutes">Minutes</a></li> 
      <li><a href="/docs">Documents</a></li> 
      <li><a href="/contact">Contact Us</a></li> 
     </ul> 
    </div> 
    <!-- end #menu --> 
</div> 
<div id="page"> 
    <div id="content"> 
     <div class="post"> 
      <h2 class="title"><a href="#">Edit Information</a></h2> 
      <div style="clear: both;"><form action="/admin"><input type="submit" value='Back'/></form></div> 
<div style="clear: both;"></div> 
      <div class="entry"> 

      <SCRIPT language="javascript"> 
      function add() { 
       x++; 
       var foo = document.getElementById('my_div'); 
       foo.innerHTML = foo.innerHTML +"<input type='text' name='tg"+x+"' placeholder='name'><br />"; 
      } 
      function addch() { 
       y++; 
       var foo = document.getElementById('my_other_div'); 
       foo.innerHTML = foo.innerHTML +"<input type='text' name='ch"+y+"' placeholder='name'><br />"; 
      } 
      function addws() { 
       z++; 
       var foo = document.getElementById('my_other_other_div'); 
       foo.innerHTML = foo.innerHTML +"<input type='text' name='ws"+z+"' placeholder='workshop name and leaders' style='width: 98%;'><br />"; 
      } 
      function detect(form) { 
       if(form.checked) { 
        window.backUpHtml = document.getElementById('con_div').innerHTML; 
        document.getElementById('con_div').innerHTML = ''; 
       } else { 
        document.getElementById('con_div').innerHTML = window.backUpHtml; 
        window.backUpHtml = ''; 
       } 
      } 
      </SCRIPT> 

      <form name="form1" method="post" action="./"><font color="#FFFFFF"> 
      <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#00000" style="max-width: 560px;"> 
      <tr> 
      <td width="10%">Name</td> 
      <td width="90%"><?php echo "<input name='name' type='text' value='".stripslashes($_POST['name'])."' required='required'/>"; ?><input type="checkbox" onclick="detect(this)" name="isyac" id="isyac" value="yes" <?php if(isset($_POST['isyac'])) { echo "checked='checked'";} ?> /><label for="isyac">YAC Meeting</label></td> 
      </tr> 
      <tr> 
      <td width="10%" style="vertical-align:top;">Description</td> 
      <td width="90%"><?php echo '<textarea name="desc" rows="5" cols="60" style="resize: vertical;" required="required">'.stripslashes($_POST["desc"]).'</textarea>'; ?></td> 
      </tr> 
      <tbody id="con_div"> 
      <!-- START OF CON DIV --> 
      <tr> 
      <td width="10%" style="vertical-align:top;">Touchgroup Leaders</td> 
      <td width="90%"> 

      <?php 

      $blah = 1; 

      while(isset($_POST['tg'.$blah])) { 
       echo '<input type="text" name="tg'.$blah.'" value="'.stripslashes($_POST["tg".$blah]).'" /><br />'; 
       $blah++; 
      } 
      $hoo = $blah - 1; 
      echo "<script language='javascript'> var x = ".$hoo."; </script>"; 

      ?> 
      <div id="my_div"></div> 
      <input type="button" value="Add" onClick="add()"> 

      </td> 
      </tr> 
      <tr> 
      <td width="10%" style="vertical-align:top;">Chaplains</td> 
      <td width="90%"> 

      <?php 
       $blah = 1; 

      while(isset($_POST['ch'.$blah])) { 
       echo '<input type="text" name="ch'.$blah.'" value="'.stripslashes($_POST["ch".$blah]).'" /><br />'; 
       $blah++; 
      } 
      $hoo = $blah - 1; 
      echo "<script language='javascript'> var y = ".$hoo."; </script>"; 

      ?> 
      <div id="my_other_div"></div> 
      <input type="button" value="Add" onClick="addch()"> 

      </td> 
      </tr> 
      <tr> 
      <td width="10%" style="vertical-align:top;">Workshops</td> 
      <td width="90%"> 

      <?php 
       $blah = 1; 

      while(isset($_POST['ws'.$blah])) { 
       echo '<input type="text" name="ws'.$blah.'" value="'.stripslashes($_POST["ws".$blah]).'" style="width: 98%;"/><br />'; 
       $blah++; 
      } 
      $hoo = $blah - 1; 
      echo "<script language='javascript'> var z = ".$hoo."; </script>"; 

      ?> 
      <div id="my_other_other_div"></div> 
      <input type="button" value="Add" onClick="addws()"> 

      </td> 
      </tr> 
      </tbody> 
      <!-- END OF CON DIV --> 
      <tr> 
      <td width="10%" style="vertical-align:top;">Registration Links</td> 
      <td width="90%"> 

      <?php echo '<input type="text" name="YouthLink" value="'.stripslashes($_POST['YouthLink']).'"/>&nbsp;Youth Link<br /> 
      <input type="text" name="AdultLink" value="'.stripslashes($_POST['AdultLink']).'"/>&nbsp;Adult Link'; ?> 

      </td> 
      </tr> 
      <tr> 
      <td width="10%" style="vertical-align:top;">Start Date</td> 
      <td width="90%"> 

      <select name='startmonth'> 
       <?php $idk = array("January","February","March","April","May","June","July","August","September","October","November","December"); 

       foreach ($idk as $bob): 

       if($bob = $_POST['startmonth']) { 
        echo '<option value="'.$bob.'" selected="selected">'.$bob.'</option>'; 
       } else { 
        echo '<option value="'.$bob.'">'.$bob.'</option>'; 
       } 

       endforeach; 

       ?> 
      </select> 
      <select name="startday"> 
       <?php 

       $x = 1; 
       while($x <= 31) { 
        if((int)$_POST['startday'] == $x) { 
         echo "<option value='".$x."' selected='selected'>".$x."</option>"; 
        } else { 
         echo "<option value='".$x."'>".$x."</option>"; 
        } 
        $x++; 
       } 

       ?> 
      </select> 
      <select name="startyear"> 
       <?php $date = getdate(); 
       for($x = 0;$x < 3;$x++) { 
        $y = (int)$date['year']+$x; 
        if($y == $_POST['startyear']) { 
        echo "<option value='".$y."' selected='selected'>".$y."</option>"; 
        } else { 
        echo "<option value='".$y."'>".$y."</option>"; 
        } 
       } 
       ?> 
      </select> 

      </td> 
      </tr> 
      <tr> 
      <td width="10%" style="vertical-align:top;">End Date</td> 
      <td width="90%"> 

      <select name='endmonth'> 
       <?php $idk = array("January","February","March","April","May","June","July","August","September","October","November","December"); 

       foreach ($idk as $bob): 

       if($bob = $_POST['endmonth']) { 
        echo '<option value="'.$bob.'" selected="selected">'.$bob.'</option>'; 
       } else { 
        echo '<option value="'.$bob.'">'.$bob.'</option>'; 
       } 

       endforeach; 

       ?> 
      </select> 
      <select name="endday"> 
       <?php 

       $x = 1; 
       while($x <= 31) { 
        if((int)$_POST['endday'] < $x) { 
         echo "<option value='".$x."'>".$x."</option>"; 
        } else if((int)$_POST['endday'] == $x) { 
         echo "<option value='".$x."' selected='selected'>".$x."</option>"; 
        } else if((int)$_POST['endday'] > $x) { 
         echo "<option value='".$x."'>".$x."</option>"; 
        } 
        $x++; 
       } 

       ?> 
      </select> 
      <select name="endyear"> 
       <?php $date = getdate(); 
       for($x = 0;$x < 3;$x++) { 
        $y = (int)$date['year']+$x; 
        if($y == $_POST['endyear']) { 
         echo "<option value='".$y."' selected='selected'>".$y."</option>"; 
        } else { 
         echo "<option value='".$y."'>".$y."</option>"; 
        } 
       } 
       ?> 
      </select> 

      </td> 
      </tr> 
      <tr> 
      <td width="10%" style="vertical-align:top;">Location</td> 
      <td width="90%"> 

       <?php echo '<input type="text" name="location" value="'.stripslashes($_POST['location']).'" required="required"/>'; ?> 

      </td> 
      </tr> 
      <tr> 
      <td width="90%"></td> 
      <td width="10%"> 

       <input type="hidden" name="blah" value="blah"/> 
       <input type="submit" name="woohoo" value="Save" align="right"/> 

      </td> 
      </table> 
      </form> 
       <?php if(isset($_POST['isyac'])) { 
       echo "<script language='javascript'>window.backUpHtml = document.getElementById('con_div').innerHTML; 
       document.getElementById('con_div').innerHTML = '';</script>"; ?> 
      } 
      </div> 

     </div> 

<div style="clear: both;">&nbsp;</div> 
    </div> 
    <!-- end #content --> 
    <div id="sidebar"> 
     <?php include($_SERVER['DOCUMENT_ROOT'].'/resources/side.php'); ?> 
    </div> 
    <!-- end #sidebar --> 
    <div style="clear: both;">&nbsp;</div> 
</div> 
<!-- end #page --> 
<div id="footer-menu"> 
    <ul> 
      <li class="current_page_item"><a href="/">Home</a></li> 
      <li><a href="/events">Events</a></li> 
      <li><a href="/forum">Forums</a></li> 
      <li><a href="/about">About</a></li> 
      <li><a href="/minutes">Minutes</a></li> 
      <li><a href="/docs">Documents</a></li> 
      <li><a href="/contact">Contact Us</a></li> 
    </ul> 
</div> 
<div id="footer"> 
    <p>Copyright &copy; <?php $date = getdate(); echo $date['year']; ?> My Website. All rights reserved.</p> 
</div> 
<!-- end #footer --> 
</body> 
</html> 
+2

你能指出哪一行是318吗?这将有助于不必将其复制到文本编辑器中以找到它。 – airplaneman19 2012-02-16 02:00:12

+0

在编写模板时,考虑在将来使用[备选语法](http://www.php.net/manual/en/control-structures.alternative-syntax.php),以避免这些类型的问题。 – rid 2012-02-16 02:07:35

+0

为什么人们会投票?他提供了一个代码链接。我花了3秒钟点击链接并找到第318行。 – 2012-02-16 02:10:01

回答

3

你的问题来自于这段代码:

   <?php if(isset($_POST['isyac'])) { 
      echo "<script language='javascript'>window.backUpHtml = document.getElementById('con_div').innerHTML; 
      document.getElementById('con_div').innerHTML = '';</script>"; ?> 
     } 

右括号}需要是PHP标签(前?>

+0

啊,工作完美 – DontTurnAround 2012-02-16 02:06:26

2

内我只是看了你的代码,我会说这可能是这样的:

</form> 
       <?php if(isset($_POST['isyac'])) { 
       echo "<script language='javascript'>window.backUpHtml = document.getElementById('con_div').innerHTML; 
       document.getElementById('con_div').innerHTML = '';</script>"; ?> 
      } 
      </div> 

你的底卷曲应该在里面吗?>

</form> 
       <?php if(isset($_POST['isyac'])) { 
       echo "<script language='javascript'>window.backUpHtml = document.getElementById('con_div').innerHTML; 
       document.getElementById('con_div').innerHTML = '';</script>"; 
       } 
       ?> 
      </div>