Confused why code will only work with ob_start();
<p>I have added some server side validation to a dropdown box on one of my pages and when I did the page wouldn't work anymore. The code I added is as follows:</p>

<pre><code>$show_form = true;        
if (isset($_POST['submit'])) {
    //All of the server side validations   
      $validator = new FormValidator();
    $validator-&gt;addValidation("hospital_name","dontselect=000","No facility was chosen");

    if ($validator-&gt;ValidateForm()) {
    // All the variables from the submission form   
    $userid = $_SESSION['user_id'];
    $hosp = $_POST['hospital_name'];
   header('Location: ../site_hospital' . $hosp . '/hospital_submitform.php?usr=' . $userid . '&amp;&amp;hosp=' . $hosp);
    exit;
    $show_form = false;
    } else {
    echo "&lt;B style='color:red;'&gt;The following errors occurred:&lt;/B&gt;";
    $error_hash = $validator-&gt;GetErrors();
    foreach ($error_hash as $inpname =&gt; $inp_err) {
        echo "&lt;p style='color:red;'&gt;$inp_err&lt;/p&gt;\n";
    }
}}        
if (true == $show_form) {
</code></pre>

<p>Through pure chance I added ob_start(); as part of my debugging to the beginning of the page and suddenly my code worked properly but I have no idea why and I was hoping the community could throw out an educated guess as to why. When the code stopped working it would not execute my header command above, the page would simply refresh and not change location, when I added ob_start(); to the top of the page the page redirected as planned. So the overall question is why would the page not direct using the header command without ob_start? I'm sure alot more detail and code is necessary for a definitive answer but I'm hoping someone has run into this before or has an educated guess that may lead me to my own answers. Thanks for any insight.</p>
