473,387 Members | 1,535 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,387 software developers and data experts.

why "header" does not work in my code?

hello ^^


i used header in my codes, and it was working fine in the local server. but when i upload it to the public server i keep get the following error:

Warning: Cannot modify header information - headers already sent by (output started at /home/movc/public_html/dbconnector.php:23) in /home/movc/public_html/loginaction.php on line 31


in dbconnector.php :
i connect to the server and i never used header there!

and in loginaction.php i used:
[code] include_once("dbconnector.php"); [/DODE]

and this is the part of my code that i used header in:
Expand|Select|Wrap|Line Numbers
  1.  
  2.     //Check whether the query was successful or not
  3.     if($result) {
  4.         header('location: welcome_msg1.php');
  5. exit();}
  6.     else
  7.     header('location: erorr_msg1.php');
  8. exit(); 
  9.  

can you please tell me where i did wrong?
thanks so much ^^
May 11 '12 #1
5 1841
Dormilich
8,658 Expert Mod 8TB
it’s like the error messages says, 8 lines before you set the header, you have output, which causes the response body to begin and which renders any more headers invalid.
May 12 '12 #2
thank you so much ^^ :*

but, what kind of error?
i review the code many times and couldn't find it!

if you can help me more and see the code:
Expand|Select|Wrap|Line Numbers
  1. //Create query
  2.  
  3.     $qry="SELECT * FROM user WHERE username='"$un"' AND pw='"$pw"';";
  4.     $result=mysql_query($qry);
  5.  
  6.     //Check whether the query was successful or not
  7.     if($result) {
  8.     if(mysql_num_rows($result) == 1) {
  9.             //Login Successful
  10.  
  11.             $member = mysql_fetch_assoc($result);
  12.             $_SESSION['uid'] = $member['u_id'];
  13.  
  14.             header("location: controlpanel.php");
  15.  
  16.             exit();
  17.         }else {
  18.             //Login failed
  19.             header("location: index.php");
  20.  
  21.             exit();
  22.         }
  23.     }else {
  24.         die("Query failed");
  25.     }
  26.  
  27.  
May 14 '12 #3
Dormilich
8,658 Expert Mod 8TB
that kind of error:
Warning: Cannot modify header information - headers already sent by (output started at /home/movc/public_htm/dbconnector.php:23) in /home/movc/public_html/loginaction.php on line 31
May 14 '12 #4
^^
i mean the error in the code!
what i should change in my code to make this error msg stop!!
May 14 '12 #5
Dormilich
8,658 Expert Mod 8TB
remove the output before the header() call.
May 14 '12 #6

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

Similar topics

7
by: beliavsky | last post by:
Ideally, one can use someone's C++ code by just looking at the header files (which should contain comments describing the functions in addition to function definitions), without access to the full...
4
by: Mikkel christensen | last post by:
Hi there I wonder if any of you could point me in a direction where I can find some usefull information about coding standarts. I have some generel experiense in programming but I lack many...
8
by: Chris Markle | last post by:
When JavaScript writes out a dialogue box (like when confirm() is called) the header or title of that dialogue box shows up as "JavaScript Application"... Can this title be changed so that maybe...
16
by: a | last post by:
Hi everybody, My config: Win XP (or 2003), Apache 2.0.54, PHP 5.1.2. I have been trying to handle the case of a lenghty opearation on the server while providing the user with feedback and...
28
by: fred.haab | last post by:
Not having server side scripting, I've been doing this for "last modified" tags on my pages: <div class="modified"> <script type="Text/JavaScript"> <!-- document.write("This page was last...
6
by: dhillarun | last post by:
Hi everybody, I displaying file download window("save-as dialog box") using PHP "header()" function. How to track that user have clicked "save" button or "cancel" button???
45
by: Umesh | last post by:
please help. thanks.
1
by: kang jia | last post by:
hi i don;t know what is the difference between"Header" and "Meta" data in PHP, as they all can redirect web page. anyone can help me, it is very urgent!! thaks
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.