Re: Include and Header(Location : ) not working together
*** geshan escribió/wrote (26 Aug 2006 22:36:45 -0700):
In php5 I am not able to use include funciton and header("locatio n:"""
together please help.
In what sense aren't you able? I mean, you just type the code as usual,
don't you? What prevents you from doing so?
I'll make an exercise of fortune telling. You've upgraded to PHP 5 and you
are using the default settings in php.ini, where display_errors is
disabled. Enable it this way:
display_errors = On
error_reporting = E_ALL
When you do so, the PHP interpreter will say you cannot insert a header
because output already started. You cannot print anything into the page
before using the header() function. That includes blank lines outside the
<?php ?tags.
Re: Include and Header(Location : ) not working together
these are the errors i get,
Warning: session_start() [function.sessio n-start]: Cannot send session
cookie - headers already sent by (output started at
D:\Xampp\xampp\ htdocs\GM_PHP\i ncludes\conn1.p hp:11) in
D:\Xampp\xampp\ htdocs\GM_PHP\l ogin_process.ph p on line 2
Warning: session_start() [function.sessio n-start]: Cannot send session
cache limiter - headers already sent (output started at
D:\Xampp\xampp\ htdocs\GM_PHP\i ncludes\conn1.p hp:11) in
D:\Xampp\xampp\ htdocs\GM_PHP\l ogin_process.ph p on line 2
Warning: Cannot modify header information - headers already sent by
(output started at D:\Xampp\xampp\ htdocs\GM_PHP\i ncludes\conn1.p hp:11)
in D:\Xampp\xampp\ htdocs\GM_PHP\l ogin_process.ph p on line 38
i'm using xampp with php, Apache 2.2 and mysql 4.01
I'm posting the login_process.p hp file here, it is made for a login
system plesae help:
$sql="SELECT password FROM tbl_users WHERE user_name = '$username'
and user_status=1";
$users_in=mysql _query($sql) or die(mysql_error ());
$pass_db=mysql_ result($users_i n,0,0);
Re: Include and Header(Location : ) not working together
geshan wrote:
these are the errors i get,
>
Warning: session_start() [function.sessio n-start]: Cannot send session
cookie - headers already sent by (output started at
D:\Xampp\xampp\ htdocs\GM_PHP\i ncludes\conn1.p hp:11) in
D:\Xampp\xampp\ htdocs\GM_PHP\l ogin_process.ph p on line 2
>
Warning: session_start() [function.sessio n-start]: Cannot send session
cache limiter - headers already sent (output started at
D:\Xampp\xampp\ htdocs\GM_PHP\i ncludes\conn1.p hp:11) in
D:\Xampp\xampp\ htdocs\GM_PHP\l ogin_process.ph p on line 2
>
Warning: Cannot modify header information - headers already sent by
(output started at D:\Xampp\xampp\ htdocs\GM_PHP\i ncludes\conn1.p hp:11)
in D:\Xampp\xampp\ htdocs\GM_PHP\l ogin_process.ph p on line 38
>
<code snipped>
>
I need help. Please Help Fast
>
Just like it said - line 11 of includes\conn1. php is causing output to
be sent to the browser. This forces the headers to be sent to the
browser. session_start() must be called before ANY output is sent to
the browser.
The output could be from an echo or print statement, for instance. Or
it could be just whitespace outside of the <?php ... ?brackets. Any
output will cause the headers to be sent.
The only confusing factor here is that you don't include
include\conn1.p hp until after the session_start() command. It looks
like this isn't your exact code, or perhaps your login_process.p hp is
itself included in another file.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. jstucklex@attgl obal.net
=============== ===
Re: Include and Header(Location : ) not working together
Dear Jerry,
Thank you very much but i solved the problem. The problem was n
conn1.php where i have left three blank lines after the code that was
causing the errors.
Comment