2014-11-02 81 views
0

有相当多的解决方案可用于此错误,但似乎没有任何工作适合我。我是一个新的PHP开发人员,并试图使用PHP程序创建网站。没有得到错误的原因

我收到的错误是“警告:无法修改头信息 - 头文件已经由/ home/influss/public_html /中的/home/influss/public_html/Influsstest/hiremain.php:39发送(输出开始) Influsstest/hiremain.php on line 74“

我已经检查了行号。 39并且在php之前或之后没有找到任何空格。在程序开始或结束时也没有空白,但仍然出现此错误。

的代码如下:

`

<!doctype html> 
<html><!-- InstanceBegin template="/Templates/registrtion.dwt" codeOutsideHTMLIsLocked="false" --> 
<head> 
<!-- InstanceBeginEditable name="doctitle" --> 
<title>Hire Main</title> 
<!-- InstanceEndEditable --> 
    <link href="/css/styles-reg.css" rel="stylesheet" type="text/css" media="all"> 
    <link href="/css/reg.css" rel="stylesheet" type="text/css" media="all"/> 
    <link href='http://fonts.googleapis.com/css?family=Roboto:400,500' rel='stylesheet' type='text/css'> 
    <link href='http://fonts.googleapis.com/css?family=Roboto+Condensed:400,700' rel='stylesheet' type='text/css'> 
    <link href='http://fonts.googleapis.com/css?family=Raleway:400,600,900,700' rel='stylesheet' type='text/css'> 
    <link href='http://fonts.googleapis.com/css?family=Slabo+13px' rel='stylesheet' type='text/css'> 
    <link href='http://fonts.googleapis.com/css?family=Rokkitt:400,700' rel='stylesheet' type='text/css'> 
    <!-- InstanceBeginEditable name="head" --> 
     <link href="css/styles.css" rel="stylesheet" type="text/css" media="all"> 
    <!-- InstanceEndEditable --> 
</head> 
<body> 
    <div id="wrapper"> 
     <div id="top"> 
      <div id = "logo"> 
       <img src="images/logo2.jpg"> 
      </div> 
      <div id = "social-media"> 
       <p>For additional information<br>Call Phone No.</p> 
       <ul> 
        <li><a href="http://wwww.facebook.com"><img src="/images/icons/facebook1.png"></a></li> 
        <li><a href="http://wwww.twitter.com"><img src="/images/icons/twitter1.png"></a></li> 
        <li><a href="http://wwww.linkedin.com"><img src="/images/icons/linkedin1.png"></a></li> 
        <li><a href="http://wwww.plus.google.com"><img src="/images/icons/googleplus1.png"></a></li> 
       </ul> 
       </div> 
     </div> 
<!--  <div id="Banner"> 
     </div> 
-->  <div id="Content-wrapper"> 
      <div id="content"> 
      <!-- InstanceBeginEditable name="content" --> 
**<?php** 
        error_reporting(E_ALL); ini_set('display_errors', 'On');     
        function renderForm($id, $error) 
        { 
?> 
<?php 
         if ($error != '') 
         { 
          echo '<div style="margin:0 200px;padding:4px; color:red ;font-weight:bold;">'.$error.'</div>'; 
         } 
?> 
         <form action="hiremain.php" method="post" class="newreg"> 
          <fieldset class="row1"> 
           <p> 
           <label class="labelstyle">Enter Registration ID: *</label> 
           <input type="text" name="regid" value="<?php echo $id;?>"/> 
           </p> 
          </fieldset> 
          <p></p> 
          <input class="button1" type="submit" name="submit" value="Get Details"> 
         </form> 
         <p></p> 
<?php 
        } 
?> 
<?php 
        include('connect.php'); 
        if (isset($_POST['submit'])) 
        { 
         $id = $_POST['regid']; 
         $sql = "Select * from hirefinal where hr_id = '$id'"; 
         $result = mysql_query($sql) or die(mysql_error()); 
         $total_results = mysql_num_rows($result); 
         if ($total_results > 0) 
         { 
          header('location:hireedit.php?regid='.$id); 
         } 
         else 
         { 
          $id = $_POST['regid']; 
          $sql = "Select * from hirefinal where hr_id = '$id'"; 
          $result = mysql_query($sql) or die(mysql_error()); 
          $total_results = mysql_num_rows($result); 
          if ($total_results > 0) 
          { 
           header("location:hireedit.php?regid=" . $id); 
          } 
          Else 
          {     
           $error = "Please register first"; 
           renderForm($id, $error);  
          } 
         } 
         mysql_free_result($result); 
        } 
        else 
        { 
         $error = ""; 
         $id=""; 
         renderform($id, $error); 
        } 
?> 
       <a href="hireent.php" class="linkstyle">Register a Request</a> 
       <a href="index.html" class="linkstyle">Home</a> 
       <p></p> 
       <!-- InstanceEndEditable --> 
      </div> 
     </div> 
     <div id="footer"> 
      <p>&copy;Copyright 2014 &bull; All rights Reserved &bull; Influss.com, Chennai, Mob: +9112345-12345, E-mail: [email protected]</p> 
     </div> 
    </div> 
</body> 
<!-- InstanceEnd --> 
</html> 

` 错误恰好是在由*标记的行。

请求有人帮我解决这个问题。

回答

1

您不能在html输出后发送标题。

<?php 
error_reporting(E_ALL); ini_set('display_errors', 'On');     
function renderForm($id, $error) 
{ 
if ($error != '') 
{ 
$problems = '<div style="margin:0 200px;padding:4px; color:red ;font-weight:bold;">'.$error.'</div>'; 
        } 
} 
include('connect.php'); 
if (isset($_POST['submit'])) 
{ 
$id = $_POST['regid']; 
$sql = "Select * from hirefinal where hr_id = '$id'"; 
$result = mysql_query($sql) or die(mysql_error()); 
$total_results = mysql_num_rows($result); 
if ($total_results > 0) 
{ 
header('location:hireedit.php?regid='.$id); 
} 
else 
{ 
$id = $_POST['regid']; 
$sql = "Select * from hirefinal where hr_id = '$id'"; 
$result = mysql_query($sql) or die(mysql_error()); 
$total_results = mysql_num_rows($result); 
if ($total_results > 0) 
{ 
header("location:hireedit.php?regid=" . $id); 
} 
Else 
{     
$error = "Please register first"; 
renderForm($id, $error);  
} 
} 
mysql_free_result($result); 
} 
else 
{ 
$error = ""; 
$id=""; 
renderform($id, $error); 
} 
    ?> 
    <!doctype html> 
    <html><!-- InstanceBegin template="/Templates/registrtion.dwt" codeOutsideHTMLIsLocked="false" --> 
    <head> 
    <!-- InstanceBeginEditable name="doctitle" --> 
    <title>Hire Main</title> 
    <!-- InstanceEndEditable --> 
     <link href="/css/styles-reg.css" rel="stylesheet" type="text/css" media="all"> 
     <link href="/css/reg.css" rel="stylesheet" type="text/css" media="all"/> 
     <link href='http://fonts.googleapis.com/css?family=Roboto:400,500' rel='stylesheet' type='text/css'> 
     <link href='http://fonts.googleapis.com/css?family=Roboto+Condensed:400,700' rel='stylesheet' type='text/css'> 
     <link href='http://fonts.googleapis.com/css?family=Raleway:400,600,900,700' rel='stylesheet' type='text/css'> 
     <link href='http://fonts.googleapis.com/css?family=Slabo+13px' rel='stylesheet' type='text/css'> 
     <link href='http://fonts.googleapis.com/css?family=Rokkitt:400,700' rel='stylesheet' type='text/css'> 
     <!-- InstanceBeginEditable name="head" --> 
      <link href="css/styles.css" rel="stylesheet" type="text/css" media="all"> 
     <!-- InstanceEndEditable --> 
    </head> 
    <body> 
     <div id="wrapper"> 
      <div id="top"> 
       <div id = "logo"> 
        <img src="images/logo2.jpg"> 
       </div> 
       <div id = "social-media"> 
        <p>For additional information<br>Call Phone No.</p> 
        <ul> 
         <li><a href="http://wwww.facebook.com"><img src="/images/icons/facebook1.png"></a></li> 
         <li><a href="http://wwww.twitter.com"><img src="/images/icons/twitter1.png"></a></li> 
         <li><a href="http://wwww.linkedin.com"><img src="/images/icons/linkedin1.png"></a></li> 
         <li><a href="http://wwww.plus.google.com"><img src="/images/icons/googleplus1.png"></a></li> 
        </ul> 
        </div> 
      </div> 
    <!--  <div id="Banner"> 
      </div> 
    -->  <div id="Content-wrapper"> 
       <div id="content"> 
        <!-- InstanceBeginEditable name="content" --> 
<?php 
echo $problems; 
?> 
           <form action="hiremain.php" method="post" class="newreg"> 
            <fieldset class="row1"> 
             <p> 
             <label class="labelstyle">Enter Registration ID: *</label> 
             <input type="text" name="regid" value="<?php echo $id;?>"/> 
             </p> 
            </fieldset> 
            <p></p> 
            <input class="button1" type="submit" name="submit" value="Get Details"> 
           </form> 
           <p></p> 
         <a href="hireent.php" class="linkstyle">Register a Request</a> 
         <a href="index.html" class="linkstyle">Home</a> 
         <p></p> 
         <!-- InstanceEndEditable --> 
       </div> 
      </div> 
      <div id="footer"> 
       <p>&copy;Copyright 2014 &bull; All rights Reserved &bull; Influss.com, Chennai, Mob: +9112345-12345, E-mail: [email protected]</p> 
      </div> 
     </div> 
    </body> 
    <!-- InstanceEnd --> 
    </html> 
+0

是否要删除这条线需要:
你面前把他们

<!doctype html> 

您可以使用解决呢?你可以多给一点这个细节吗? – sgsandy 2014-11-02 17:33:52

+0

@sgsandy否:你必须在*那一行之前发送标题*我已经用你应该使用的代码更新了我的答案 – Stubborn 2014-11-02 17:35:13

+0

谢谢固执的答案 – sgsandy 2014-11-02 17:55:12