Re: [PHP] uh, oh errors?
[EMAIL PROTECTED] wrote: > > What are some benefits to using output buffering versus just letting it > generate as it goes? Pros: - headers can be added at any time - buffer content can be post processed (gz compression) (xslt) - if an error occurs can avoid serving half a document Cons: - transmission of content doesn't start until preprocessor completes - slightly more overhead since content must be stored in memory until buffer is flushed. Cheers, Rob. -- .-. | Robert Cummings | :-`. | Webdeployer - Chief PHP and Java Programmer | :--: | Mail : mailto:[EMAIL PROTECTED] | | Phone : (613) 731-4046 x.109 | :--: | Website : http://www.webmotion.com | | Fax : (613) 260-9545 | `--' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] uh, oh errors?
one REALLY notable advantage is: if you us ob_*() functions, instead of writing HTML pages with php tags inserted, you can write XML pages with PHP tags inserted. then after you're done, you can pass the contents of the output buffer to an XSLT processer like sablotron, THEN outputting an HTML page. -jerome Original Message Follows From: [EMAIL PROTECTED] To: [EMAIL PROTECTED], [EMAIL PROTECTED] Subject: RE: [PHP] uh, oh errors? Date: Thu, 16 May 2002 13:43:30 -0400 What are some benefits to using output buffering versus just letting it generate as it goes? -Original Message- From: Kevin Stone [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 16, 2002 1:24 PM To: PHP-general Subject: Fw: [PHP] uh, oh errors? Don't feel bad about this. This is something that messes a lot of people up. The browser knows where your headers end and where content begins by adding blank line between the headers and the rest of the page. ALL headers must come before any content is printed to the page. PHP will give you that error if you attempt to write a new header. So in fact your problem is not on Line 13.. but is actually on Line 11. There are at least two ways to avoid this... 1. Don't print content before headers. :) 2. Use output buffering to write the whole page before it is outputed to the browser. Hope this helps, -Keivn - Original Message - From: "Jas" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, May 16, 2002 11:10 AM Subject: [PHP] uh, oh errors? > Not sure how to resolve this, looked at php.net for the headers available > and this is the error I am recieving: > > Warning: Cannot add header information - headers already sent by (output > started at /path/to/connection/script/db.php:6) in /path/to/login/checking > file/auth_done.php on line 13 > > Here is the code that is in auth_done.php: > > session_start(); > require '/path/to/login/checking file/db.php'; > $db_table = 'auth_users'; > $sql = "SELECT * from $db_table WHERE un = \"$u_name\" AND pw = > password(\"$p_word\")"; > $result = @mysql_query($sql,$dbh) or die("Couldn't execute query"); > $num = mysql_numrows($result); > if ($num !=0) { > session_register('u_name'); > session_register('p_word'); > $msg_success = "Good freakin job poindexter!!"; > } else { > header ("Location: index.php"); // This is line 13 that is my error > generator > } > > This is the code for the db.php script: > $dbh = mysql_connect('localhost','username','password') or die('Could not > connect to database, please try again later'); > mysql_select_db('db_name') or die('Could not select database, please try > again later'); > ?> > > Any help would be great! I am assuming there is another way to redirect > users besides the header function, just not sure what it is or how to use > it. Thanks in advance, > Jas > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ Chat with friends online, try MSN Messenger: http://messenger.msn.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] uh, oh errors?
What are some benefits to using output buffering versus just letting it generate as it goes? -Original Message- From: Kevin Stone [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 16, 2002 1:24 PM To: PHP-general Subject: Fw: [PHP] uh, oh errors? Don't feel bad about this. This is something that messes a lot of people up. The browser knows where your headers end and where content begins by adding blank line between the headers and the rest of the page. ALL headers must come before any content is printed to the page. PHP will give you that error if you attempt to write a new header. So in fact your problem is not on Line 13.. but is actually on Line 11. There are at least two ways to avoid this... 1. Don't print content before headers. :) 2. Use output buffering to write the whole page before it is outputed to the browser. Hope this helps, -Keivn - Original Message - From: "Jas" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, May 16, 2002 11:10 AM Subject: [PHP] uh, oh errors? > Not sure how to resolve this, looked at php.net for the headers available > and this is the error I am recieving: > > Warning: Cannot add header information - headers already sent by (output > started at /path/to/connection/script/db.php:6) in /path/to/login/checking > file/auth_done.php on line 13 > > Here is the code that is in auth_done.php: > > session_start(); > require '/path/to/login/checking file/db.php'; > $db_table = 'auth_users'; > $sql = "SELECT * from $db_table WHERE un = \"$u_name\" AND pw = > password(\"$p_word\")"; > $result = @mysql_query($sql,$dbh) or die("Couldn't execute query"); > $num = mysql_numrows($result); > if ($num !=0) { > session_register('u_name'); > session_register('p_word'); > $msg_success = "Good freakin job poindexter!!"; > } else { > header ("Location: index.php"); // This is line 13 that is my error > generator > } > > This is the code for the db.php script: > $dbh = mysql_connect('localhost','username','password') or die('Could not > connect to database, please try again later'); > mysql_select_db('db_name') or die('Could not select database, please try > again later'); > ?> > > Any help would be great! I am assuming there is another way to redirect > users besides the header function, just not sure what it is or how to use > it. Thanks in advance, > Jas > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] uh, oh errors?
DOH! I retract that statement about Line 11.. I saw it and immediately thought you were printing out that line, clearly you're not. But the rest of my point is still valid, and Rasmus pointed out the true location of the error. Anyway glad to hear you got the problem solved so quickly. - Original Message - From: "Kevin Stone" <[EMAIL PROTECTED]> To: "PHP-general" <[EMAIL PROTECTED]> Sent: Thursday, May 16, 2002 11:23 AM Subject: Fw: [PHP] uh, oh errors? > Don't feel bad about this. This is something that messes a lot of people > up. The browser knows where your headers end and where content begins by > adding blank line between the headers and the rest of the page. ALL headers > must come before any content is printed to the page. PHP will give you that > error if you attempt to write a new header. So in fact your problem is not > on Line 13.. but is actually on Line 11. There are at least two ways to > avoid this... > > 1. Don't print content before headers. :) > 2. Use output buffering to write the whole page before it is outputed to the > browser. > > Hope this helps, > -Keivn > > - Original Message - > From: "Jas" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, May 16, 2002 11:10 AM > Subject: [PHP] uh, oh errors? > > > > Not sure how to resolve this, looked at php.net for the headers available > > and this is the error I am recieving: > > > > Warning: Cannot add header information - headers already sent by (output > > started at /path/to/connection/script/db.php:6) in /path/to/login/checking > > file/auth_done.php on line 13 > > > > Here is the code that is in auth_done.php: > > > > session_start(); > > require '/path/to/login/checking file/db.php'; > > $db_table = 'auth_users'; > > $sql = "SELECT * from $db_table WHERE un = \"$u_name\" AND pw = > > password(\"$p_word\")"; > > $result = @mysql_query($sql,$dbh) or die("Couldn't execute query"); > > $num = mysql_numrows($result); > > if ($num !=0) { > > session_register('u_name'); > > session_register('p_word'); > > $msg_success = "Good freakin job poindexter!!"; > > } else { > > header ("Location: index.php"); // This is line 13 that is my error > > generator > > } > > > > This is the code for the db.php script: > > > $dbh = mysql_connect('localhost','username','password') or die('Could not > > connect to database, please try again later'); > > mysql_select_db('db_name') or die('Could not select database, please try > > again later'); > > ?> > > > > Any help would be great! I am assuming there is another way to redirect > > users besides the header function, just not sure what it is or how to use > > it. Thanks in advance, > > Jas > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] uh, oh errors?
That worked, I had about 3 blank lines trailing my ?>. Thanks a ton! Jas "Rasmus Lerdorf" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > What is on line 6 of the db.php file? Do you have a stray carriage return > at the end of this file? > > On Thu, 16 May 2002, Jas wrote: > > > Not sure how to resolve this, looked at php.net for the headers available > > and this is the error I am recieving: > > > > Warning: Cannot add header information - headers already sent by (output > > started at /path/to/connection/script/db.php:6) in /path/to/login/checking > > file/auth_done.php on line 13 > > > > Here is the code that is in auth_done.php: > > > > session_start(); > > require '/path/to/login/checking file/db.php'; > > $db_table = 'auth_users'; > > $sql = "SELECT * from $db_table WHERE un = \"$u_name\" AND pw = > > password(\"$p_word\")"; > > $result = @mysql_query($sql,$dbh) or die("Couldn't execute query"); > > $num = mysql_numrows($result); > > if ($num !=0) { > > session_register('u_name'); > > session_register('p_word'); > > $msg_success = "Good freakin job poindexter!!"; > > } else { > > header ("Location: index.php"); // This is line 13 that is my error > > generator > > } > > > > This is the code for the db.php script: > > > $dbh = mysql_connect('localhost','username','password') or die('Could not > > connect to database, please try again later'); > > mysql_select_db('db_name') or die('Could not select database, please try > > again later'); > > ?> > > > > Any help would be great! I am assuming there is another way to redirect > > users besides the header function, just not sure what it is or how to use > > it. Thanks in advance, > > Jas > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] uh, oh errors?
Hi Jas, I normally output can output a JaveScript document.location.href="XXX.XXX"; command Plan B is to do your processing before there is any output and then decide whether or not to do a redirect using the header() function. Best Regards, Patrick Lynch. Optip Ltd, Internet & Mobile Development Co. Clare, Ireland. http://www.optip.com/ -Original Message- From: Jas [mailto:[EMAIL PROTECTED]] Sent: 16 May 2002 18:11 To: [EMAIL PROTECTED] Subject: [PHP] uh, oh errors? Not sure how to resolve this, looked at php.net for the headers available and this is the error I am recieving: Warning: Cannot add header information - headers already sent by (output started at /path/to/connection/script/db.php:6) in /path/to/login/checking file/auth_done.php on line 13 Here is the code that is in auth_done.php: session_start(); require '/path/to/login/checking file/db.php'; $db_table = 'auth_users'; $sql = "SELECT * from $db_table WHERE un = \"$u_name\" AND pw = password(\"$p_word\")"; $result = @mysql_query($sql,$dbh) or die("Couldn't execute query"); $num = mysql_numrows($result); if ($num !=0) { session_register('u_name'); session_register('p_word'); $msg_success = "Good freakin job poindexter!!"; } else { header ("Location: index.php"); // This is line 13 that is my error generator } This is the code for the db.php script: Any help would be great! I am assuming there is another way to redirect users besides the header function, just not sure what it is or how to use it. Thanks in advance, Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] uh, oh errors?
What is on line 6 of the db.php file? Do you have a stray carriage return at the end of this file? On Thu, 16 May 2002, Jas wrote: > Not sure how to resolve this, looked at php.net for the headers available > and this is the error I am recieving: > > Warning: Cannot add header information - headers already sent by (output > started at /path/to/connection/script/db.php:6) in /path/to/login/checking > file/auth_done.php on line 13 > > Here is the code that is in auth_done.php: > > session_start(); > require '/path/to/login/checking file/db.php'; > $db_table = 'auth_users'; > $sql = "SELECT * from $db_table WHERE un = \"$u_name\" AND pw = > password(\"$p_word\")"; > $result = @mysql_query($sql,$dbh) or die("Couldn't execute query"); > $num = mysql_numrows($result); > if ($num !=0) { > session_register('u_name'); > session_register('p_word'); > $msg_success = "Good freakin job poindexter!!"; > } else { > header ("Location: index.php"); // This is line 13 that is my error > generator > } > > This is the code for the db.php script: > $dbh = mysql_connect('localhost','username','password') or die('Could not > connect to database, please try again later'); > mysql_select_db('db_name') or die('Could not select database, please try > again later'); > ?> > > Any help would be great! I am assuming there is another way to redirect > users besides the header function, just not sure what it is or how to use > it. Thanks in advance, > Jas > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php