473,385 Members | 1,337 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

header error on test server, not on dev

110 100+
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
4 1492
ronverdonk
4,258 Expert 4TB
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
pedalpete
110 100+
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
pedalpete
110 100+
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
4,258 Expert 4TB
Ok, best of luck.

Ronald
Feb 12 '08 #5

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

Similar topics

10
by: Bob Garbados | last post by:
forgive my ignorance, as I'm new to php coming from a ms background... If I create a page named redirect.php and it's only content is: <?php header("Location: http://www.google.com"); ?>...
9
by: soni29 | last post by:
hi, i have written the following code, still in the learning stage: #include<iostream.h> class CBox { public: // Constructor definition CBox(double lv, double bv = 1.0, double hv = 1.0) :...
0
by: ramas | last post by:
Hi, I am new to PHP scripting and i am trying to connect to a soap server (as mentioned below) using the SOAP extension comesup with PHP. Now my requirement is to add my HTTP header fields along...
3
by: pooja | last post by:
Suppose i have created a class c1 with f1()in c1.cpp and included this c1.cpp in file1.cpp file , which is also having main() by giving the statement #include "c1.cpp". the same i can do by...
60
by: Derrick Coetzee | last post by:
It seems like, in every C source file I've ever seen, there has been a very definite include order, as follows: - include system headers - include application headers - include the header...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
2
by: Axel Dahmen | last post by:
Hi, a few weeks ago I had started a thread "Can't dynamically add controls because of <%...%> code blocks". The error mentioned keeps me from inserting an automatically generated navigation menu...
21
by: cman | last post by:
does anyone know why i can't generate images with: header("Content-type:image/jpeg"); imagejpeg($img_number); i've tried different examples but i always get a text output as if the header...
2
by: Tim Ferguson | last post by:
Dear all I have a script (below) that for a long time has been sending out to an opt-in distribution list, about 100 members. Today it has stopped working and I am not quite sure what I have...
4
by: liyanage | last post by:
I recently worked on error handling and three related issues/questions came up. 1.) I am trying to trigger Apache ErrorDocument handlers by setting appropriate HTTP status codes in my PHP...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.