14pulsars Posted August 1, 2008 Share Posted August 1, 2008 Hi folks, I'm having some problems with a script I'm writing. I'm trying to use a session to store POST variables for another page, then redirect based on one of the post variables. After the user redirects, they click a few links, and come back to the redirecting page, except they see the content this time, with some form fields pre-populated using the session info. Here are the error codes I get: Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/dir/public_html/orderconfirm.php:1) in /home/dir/public_html/orderconfirm.php on line 1 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/dir/public_html/orderconfirm.php:1) in /home/dir/public_html/orderconfirm.php on line 1 Warning: Cannot modify header information - headers already sent by (output started at /home/dir/public_html/orderconfirm.php:1) in /home/dir/public_html/orderconfirm.php on line 16 Here is the code at the top of the page responsible for the work(starting from line 1) <?php session_start(); if (isset($_POST)) { if ($_GET['us'] != 'true') { foreach ($_POST as $key => $value) $_SESSION[$key] = $value; } for ($i=1;$i<20;$i++) { if(isset($_POST['sku'.$i])) { if ($_POST['sku'.$i] == "AOI0000") header('Location: http://www.sitename.com/bookthankyou.php'); elseif ($_POST['sku'.$i] == "AOI0004") header('Location: http://www.sitename.com/hardcopythankyou.php'); } else break; } } ?> I thought that the problem would be on line 1, but there is nothing but the opening PHP bracket - no empty space or anything that could cause an issue. Any thoughts on a cause for the problem? Quote Link to comment https://forums.phpfreaks.com/topic/117762-solved-output-starting-on-line-1-quotltphpquot-is-the-only-thing-on-line-1/ Share on other sites More sharing options...
DarkWater Posted August 1, 2008 Share Posted August 1, 2008 Did you save the file as UTF-8? If so, there could be a byte order mark (BOM) that you can't see at the beginning of the file. Some editors have the option to turn it off, so look. If not, open a hex editor and find it. Quote Link to comment https://forums.phpfreaks.com/topic/117762-solved-output-starting-on-line-1-quotltphpquot-is-the-only-thing-on-line-1/#findComment-605683 Share on other sites More sharing options...
LemonInflux Posted August 1, 2008 Share Posted August 1, 2008 Or if you've included the file from another, make sure you haven't already outputted anything ---------------- Now playing: Linkin Park - Numb (Live At Milton Keynes) via FoxyTunes Quote Link to comment https://forums.phpfreaks.com/topic/117762-solved-output-starting-on-line-1-quotltphpquot-is-the-only-thing-on-line-1/#findComment-605689 Share on other sites More sharing options...
14pulsars Posted August 1, 2008 Author Share Posted August 1, 2008 Did you save the file as UTF-8? If so, there could be a byte order mark (BOM) that you can't see at the beginning of the file. Some editors have the option to turn it off, so look. If not, open a hex editor and find it. Dreamweaver has the option to include a BOM - I unchecked it, still no go. Or if you've included the file from another, make sure you haven't already outputted anything Not included anywhere - I just present this page, nothing else. Thanks for your replies, though! Quote Link to comment https://forums.phpfreaks.com/topic/117762-solved-output-starting-on-line-1-quotltphpquot-is-the-only-thing-on-line-1/#findComment-605691 Share on other sites More sharing options...
DarkWater Posted August 1, 2008 Share Posted August 1, 2008 Eww, you use Dreamweaver? Anyway....try going into a hex editor and manually deleting it. I suggest XVI32 as your hex editor. =P Quote Link to comment https://forums.phpfreaks.com/topic/117762-solved-output-starting-on-line-1-quotltphpquot-is-the-only-thing-on-line-1/#findComment-605694 Share on other sites More sharing options...
LemonInflux Posted August 1, 2008 Share Posted August 1, 2008 NOTEPAD++ ftw :] Oh, and make sure there isn't a cheeky little space before the <?php ---------------- Now playing: Linkin Park - The Little Things Give You Away (Live At Milton Keynes) via FoxyTunes Quote Link to comment https://forums.phpfreaks.com/topic/117762-solved-output-starting-on-line-1-quotltphpquot-is-the-only-thing-on-line-1/#findComment-605695 Share on other sites More sharing options...
14pulsars Posted August 1, 2008 Author Share Posted August 1, 2008 NOTEPAD++ ftw :] Oh, and make sure there isn't a cheeky little space before the <?php I dropped it into notepad++ as well - no different that the Dreamweaver code view. Quote Link to comment https://forums.phpfreaks.com/topic/117762-solved-output-starting-on-line-1-quotltphpquot-is-the-only-thing-on-line-1/#findComment-605697 Share on other sites More sharing options...
DarkWater Posted August 1, 2008 Share Posted August 1, 2008 Here's what you can do. Open Notepad (regular ol' Notepad) and just copy and paste your code in: <?php session_start(); if (isset($_POST)) { if ($_GET['us'] != 'true') { foreach ($_POST as $key => $value) $_SESSION[$key] = $value; } for ($i=1;$i<20;$i++) { if(isset($_POST['sku'.$i])) { if ($_POST['sku'.$i] == "AOI0000") header('Location: http://www.sitename.com/bookthankyou.php'); elseif ($_POST['sku'.$i] == "AOI0004") header('Location: http://www.sitename.com/hardcopythankyou.php'); } else break; } } ?> And save it. Try that. Just copy and paste it from here. Quote Link to comment https://forums.phpfreaks.com/topic/117762-solved-output-starting-on-line-1-quotltphpquot-is-the-only-thing-on-line-1/#findComment-605698 Share on other sites More sharing options...
14pulsars Posted August 1, 2008 Author Share Posted August 1, 2008 Eww, you use Dreamweaver? Anyway....try going into a hex editor and manually deleting it. I suggest XVI32 as your hex editor. =P Tried XVI32, removed three small symbols from the start, and it works! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/117762-solved-output-starting-on-line-1-quotltphpquot-is-the-only-thing-on-line-1/#findComment-605701 Share on other sites More sharing options...
DarkWater Posted August 1, 2008 Share Posted August 1, 2008 Any time. =) Quote Link to comment https://forums.phpfreaks.com/topic/117762-solved-output-starting-on-line-1-quotltphpquot-is-the-only-thing-on-line-1/#findComment-605703 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.