没有得到错误的原因

时间:2014-11-02 17:27:04

标签: php

有很多解决方案可用于此错误,但似乎没有一个适用于我。我是一个新的PHP开发人员,并尝试使用PHP程序创建网站。

我得到的错误是"警告:无法修改标头信息 - 已经发送的标头(/home/influss/public_html/Influsstest/hiremain.php:39中的输出开始)/ home /在第74行"

上影响/ public_html / Influsstest / hiremain.php

我检查了行号。 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: abc@influss.com</p>
        </div>
    </div>
</body>
<!-- InstanceEnd -->
</html>

` 错误发生在由*。

标记的行中

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

1 个答案:

答案 0 :(得分:1)

您不能在html输出后发送标头 你必须把它们放在

之前
<!doctype 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: abc@influss.com</p>
            </div>
        </div>
    </body>
    <!-- InstanceEnd -->
    </html>