By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,614 Members | 1,674 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,614 IT Pros & Developers. It's quick & easy.

header error on test server, not on dev

100+
P: 110
I've just loaded some code up to my testing machine, and I get nothing but "cannot modify header" errors.
I don't get these errors on my dev machine at all.

I've gone through my code, and all my the include which I believe is causing the error is one of the first things in the page, so that shouldn't be the issue.

Is there anything else which would cause this error?

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. include '../includes/PCDBconnect.php';
  4. require_once ('facebook.php');
  5.  
  6. $company = mysql_real_escape_string(@$_POST['company']);
  7. $address = mysql_real_escape_string(@$_POST['address']);
  8. $city = mysql_real_escape_string(@$_POST['city']);
  9. $zip = mysql_real_escape_string(@$_POST['zip']);
  10. $phone = mysql_real_escape_string(@$_POST['phone']);
  11. $fName = mysql_real_escape_string(@$_POST['fName']);
  12. $lName = mysql_real_escape_string(@$_POST['lName']);
  13. $econt = mysql_real_escape_string(@$_POST['econt']);
  14.  
  15.  
  16. $process=@$_POST['process'];
  17. if($process==1){
  18.  
  19.  
  20.  
  21. $query = "SELECT cid, companyName, address, city, zip FROM company WHERE companyName = '$company' AND address='$address' AND city = '$city' AND zip = '$zip' ";
  22. $result = mysql_query($query) or die("couldn't execute search");
  23. $testDuplicate = mysql_num_rows($result);
  24.  
  25. if ($testDuplicate!='0'){
  26. $cid = $testDuplicate['cid'];
  27. echo "<html>
  28. <head>
  29.  
  30. <link rel=\"stylesheet\" type=\"text/css\" href=\"css/schedule.css\" ></head>
  31. <body>
  32. <div class=\"center\">
  33. <div class=\"header1\">
  34.     <img src=\"images/logo5-sm-whiteback.gif\" class=\"logo\">
  35.     <div class=\"topbar\">manage your company work schedule</div>
  36.     </div>
  37. this company already in database with cid = $cid<br />
  38.     click here to send a message to the company administrators
  39. </div>
  40. </body>
  41. </html>
  42.  
  43. ";
  44.  
  45. } elseif ($company!='' && $address!='' && $city!='' && $phone!=''){
  46. $sql = "INSERT INTO company (companyName, address, city, zip, phone, createdby) VALUES ('$company', '$address', '$city', '$zip', '$phone', '$user_id')";
  47.  
  48.   mysql_query($sql)or die(mysql_error()); 
  49. $cid = mysql_insert_id();
  50.  
  51. $sql2 = "INSERT INTO groups (cid, groupName) VALUES ('$cid', 'null')";
  52.  
  53.  mysql_query($sql2) or die(mysql_error());
  54. $gid = mysql_insert_id();
  55.  
  56.  $sql3 = "INSERT INTO users (fbUser_id, email, firstName, lastName, usertype, cid, gid) VALUES ('$user_id', '$econt', '$fName', '$lName', '2', '$cid', '$gid')";
  57.  
  58.     mysql_query($sql3)or die(mysql_error()); 
  59.  
  60.     header('Location: manageUG.php?cid='.$cid);
  61.     }
  62. } else {
  63.  
  64. echo  "<html>
  65. <head>
  66.  
  67. <link rel=\"stylesheet\" type=\"text/css\" href=\"css/schedule.css\" ></head>
  68. <body>
  69. <div class=\"center\">
  70. <div class=\"header1\">
  71.     <img src=\"images/logo5-sm-whiteback.gif\" class=\"logo\">
  72.     <div class=\"topbar\">manage your company work schedule</div>
  73.     </div><form class=\"addCompany\" name=\"create\" action=\"addCompany.php\" method=\"post\" /><br />
  74.     <div>
  75.     <span class=\"label\">Business Name: </span><span class=\"input\"><input type=\"text\" name=\"company\" value=\"$company\" /></span>
  76.     </div>
  77.     <div>
  78.     <span class=\"label\">Address:</span><span class=\"input\"> <input type=\"text\" name=\"address\" value=\"$address\" /></span>
  79.     <div>
  80.     <span class=\"label\">City: </span><span class=\"input\"><input type=\"text\" name=\"city\" value=\"$city\" /></span>
  81.     <div>
  82.     <span class=\"label\">Zip: </span><span class=\"input\"><input type=\"text\" name=\"zip\" value=\"$zip\"/></span>
  83.     <div>
  84.     <span class=\"label\">
  85. Phone Number: </span><span class=\"input\"><input type=\"text\" name=\"phone\" value=\"$phone\" /></span>
  86.     <div>
  87. <hr />";
  88.  
  89. $fbquery = "SELECT first_name, last_name, pic_small FROM user WHERE uid = $user_id";
  90. $fbarray = $facebook->api_client->fql_query($fbquery);
  91.  
  92. $firstName = $fbarray[0]['first_name'];
  93. $lastName = $fbarray[0]['last_name'];
  94. $img = $fbarray[0]['pic_small'];
  95.  
  96. echo "Your details to set you as the administrator (other administrators can be added later)<br />
  97. <img src=\"$img\" class=\"empImg\">
  98.     <div>
  99.     <span class=\"label\">First Name: </span><span class=\"input\"><input type=\"text\" name=\"fName\" value=\"$firstName\" /></span>
  100.     <div>
  101.     <span class=\"label\">Last Name:</span><span class=\"input\"> <input type=\"text\" name=\"lName\" value=\"$lastName\"/></span>
  102.     <div>
  103.     <span class=\"label\">e-mail:</span><span class=\"input\"> <input type=\"text\" name=\"econt\" value=\"$econt\"/></span>
  104.     <div>
  105. <input type=\"hidden\" name=\"process\" value=\"1\" />
  106. <input type=\"submit\" value=\"submit\" />
  107. </form>
  108. </div>
  109. </body>
  110. </html>";
  111.  
  112. mysql_close($con);
  113. ?>
  114.  
Feb 11 '08 #1
Share this Question
Share on Google+
4 Replies


ronverdonk
Expert 2.5K+
P: 4,258
Usualy the message reads like:
Expand|Select|Wrap|Line Numbers
  1. Warning: Cannot modify header information - headers already sent by (output started at C:\server\www\test.php:x) in C:\server\www\test.php on line y
so it includes the 2 line numbers. What was yours?

Ronald
Feb 11 '08 #2

100+
P: 110
I think my line numbers make it even more confusing ronald, I get 3 error outputs, lines 202, 202 (yes twice) and 205.

the worst part is, I only have 130 lines of code on this page, and the included page has 250.

the include is from the facebook php client, and I use that all over the place, so I'm sure the error does not exist in there.


Usualy the message reads like:
Expand|Select|Wrap|Line Numbers
  1. Warning: Cannot modify header information - headers already sent by (output started at C:\server\www\test.php:x) in C:\server\www\test.php on line y
so it includes the 2 line numbers. What was yours?

Ronald
Feb 12 '08 #3

100+
P: 110
Looking through some other posts, I found a message saying that whitespace prior to the opening php tag can cause this error.

Turns out I had two empty lines before the opening <php? tag.
I removed the lines, and the errors are gone.
Feb 12 '08 #4

ronverdonk
Expert 2.5K+
P: 4,258
Ok, best of luck.

Ronald
Feb 12 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.