php - Cannot modify header information even after using the ob_start? -


this question has answer here:

i warning php file on server not sure wrong. making ajax call javascript function server , not receive response in xmlhttp.readystate == 4 && xmlhttp.status == 200.

i tried make same call php file/mysql database located on local computer works not work remote host. also, have similar php file on server select clause different , works there not sure wrong here ?

.

warning: cannot modify header information - headers sent (output started @ /home2/marshell/public_html/cfv/getuserpostbybusnumber.php:2) in /home2/marshell/public_html/cfv/getuserpostbybusnumber.php on line 4

.

<?php ob_start(); header("access-control-allow-origin: *"); $q = intval($_get['q']);    $con=mysqli_connect("localhost","ma","ad","mars","3306");  if (mysqli_connect_errno())   {   echo "failed connect mysql: " . mysqli_connect_error();   }  $result = mysqli_query($con,"select * cfv_viewbusupdate  busnumber = ".$q."   order dateposted desc");    while($row = mysqli_fetch_array($result))   {    echo "<p>";   echo "<b><font color=\"3300cc\">#" . $row['dateposted'] . "</font></b> --";   echo "" . $row['username'] . " posted </br>";   echo "<b>bus number . </b>";   echo "<font color=\"cc0033\">" . $row['busnumber'] . "</font></br><b> going towards </b>";   echo "<font color=\"cc0033\">" . $row['direction'] . "</font></br> <b>stop name: </b>";   echo "<font color=\"cc0033\">" . $row['stopnames'] ."</font></br><b> time </b><font color=\"cc0033\">".$row['time']." </font></br><b> status </b>";   echo "<font color=\"cc0033\">" . $row['status'] . "</font> ";   echo "</br> <b> comment's  </b>: <font color=\"cc0033\">" . $row['comments'] . "</font>";   echo "</p>";   echo "<hr> ";   }  mysqli_close($con);  ?> 

.

function updateuserpost(str) {         if (window.xmlhttprequest) { // code ie7+, firefox, chrome, opera, safari         xmlhttp = new xmlhttprequest();     } else { // code ie6, ie5         xmlhttp = new activexobject("microsoft.xmlhttp");     }     xmlhttp.onreadystatechange = function () {           if (xmlhttp.readystate < 4) {                  showmodal();               }            if (xmlhttp.readystate == 4 && xmlhttp.status == 200) {               //  $('#select-choice-direction-foruserpost').html(xmlhttp.responsetext).selectmenu( "refresh");               hidemodal();              document.getelementbyid("result").innerhtml = xmlhttp.responsetext;             //alert(xmlhttp.responsetext);            }     }      xmlhttp.open("get", "http://www.xyz.uni.me/cfv/getuserpostbybusnumber.php?q="+str, true);       xmlhttp.send(); 

}

this issue happens when there white space, of time before <?php or <? tag, time in 1 of include files, @ end of file. make sure dont have spaces. error message shown point location.

i think has thing encoding. have experienced issue, while development environment windows based of time wamp (works fine), production environment linux based (issue occurs). people suggest using file encoding "utf-8 without bom" notepad++ have option. time encoding changed ftp client, check settings.

i have noticed wamp instance has following configuration in php.ini file ignores header send error buffering output.

output_buffering = on 

if change off on local environment might see header sent error.

output_buffering = off 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -