2014-11-02 88 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

相關問題