Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
banging my head for last two days to find the blank line in RSS output
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  23 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
bingo  
View profile  
 More options Nov 6 2007, 4:15 am
From: bingo <ragra...@gmail.com>
Date: Tue, 06 Nov 2007 09:15:13 -0000
Local: Tues, Nov 6 2007 4:15 am
Subject: banging my head for last two days to find the blank line in RSS output
hi,

 I am using cakePHP 1.2 and having trouble getting RSS working. My RSS
output contains one blank line before the start of the first tag,
breaking my RSS. I have checked all my modules, controllers, views,
components, and helpers for blank space but didn't find anywhere. Did
anyone experienced similar problem before and would be kind enough to
tell me where possibly I am making a mistake or how to find where I
might be inserting a blank line

Regards,
Ritesh


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
AD7six  
View profile  
 More options Nov 6 2007, 5:49 am
From: AD7six <andydawso...@gmail.com>
Date: Tue, 06 Nov 2007 02:49:03 -0800
Local: Tues, Nov 6 2007 5:49 am
Subject: Re: banging my head for last two days to find the blank line in RSS output

On Nov 6, 10:15 am, bingo <ragra...@gmail.com> wrote:

> hi,

>  I am using cakePHP 1.2 and having trouble getting RSS working. My RSS
> output contains one blank line before the start of the first tag,
> breaking my RSS. I have checked all my modules, controllers, views,
> components, and helpers for blank space but didn't find anywhere. Did
> anyone experienced similar problem before and would be kind enough to
> tell me where possibly I am making a mistake or how to find where I
> might be inserting a blank line

> Regards,
> Ritesh

Have you got any code which contains ... ?> <?php ..

There really is only one cause. you could try issuing a header as the
first line of your layout and see where it complains output already
started.

hth,

AD


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bingo  
View profile  
 More options Nov 6 2007, 6:56 am
From: bingo <ragra...@gmail.com>
Date: Tue, 06 Nov 2007 11:56:03 -0000
Local: Tues, Nov 6 2007 6:56 am
Subject: Re: banging my head for last two days to find the blank line in RSS output
hi AD7six,

I used Chris Lamp's magic command (see below) to get rid of all new
trailing blank lines

$ find -name "*.php" | xargs sed -i -e :a -e '/^\n*$/{$d;N;ba' -e '}'

The above command did help as now I am not getting any blank line
before my xml declaration. But I am still getting some blank spaces
before my xml declaration. I tried what you suggested but still not
able to find any specific problem. Based on your suggestion, I changed
my layout to look like this

//File: views/layouts/rss/default.ctp
<?xml version="1.0" encoding="UTF-8" ?>
<?php
echo '<channel>';
echo '<link>', Router::url('/', true), '</link>';
echo '<language>en-us</language>';
echo '<pubDate>', date("D, j M Y H:i:s", gmmktime()) . ' GMT', '</
pubDate>';
echo '<generator>Memento</generator>';
echo '<managingEditor>ritesh.meme...@gmail.com</managingEditor>';
echo '<webMaster>ritesh.meme...@gmail.com</webMaster>';
echo '<docs>http://blogs.law.harvard.edu/tech/rss</docs>';
echo $content_for_layout;
echo '</channel>';
?>

However if I set debug to 2, I am getting this error message

Parse error: parse error, unexpected T_STRING in D:\xampp\xampp\htdocs
\memento\app\views\layouts\rss\default.ctp on line 1

I am still clueless. :-(

Regards,
Ritesh

On Nov 6, 5:49 am, AD7six <andydawso...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mike Green  
View profile  
 More options Nov 6 2007, 7:13 am
From: Mike Green <mik...@gmail.com>
Date: Tue, 06 Nov 2007 04:13:12 -0800
Local: Tues, Nov 6 2007 7:13 am
Subject: Re: banging my head for last two days to find the blank line in RSS output
£50 says you have short_open_tags enabled in your php.ini

php thinks
<?xml version="

is actually

<?php xml version="....

Mike

On Nov 6, 11:56 am, bingo <ragra...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bingo  
View profile  
 More options Nov 6 2007, 7:37 am
From: bingo <ragra...@gmail.com>
Date: Tue, 06 Nov 2007 12:37:10 -0000
Local: Tues, Nov 6 2007 7:37 am
Subject: Re: banging my head for last two days to find the blank line in RSS output
hi Mike,

you are right..I have short_open_tags on. But how does it matter?

Also I tried to switch it off but the above error still persist.

Regards,
Ritesh

On Nov 6, 7:13 am, Mike Green <mik...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jon Bennett  
View profile  
 More options Nov 6 2007, 7:45 am
From: "Jon Bennett" <jmbenn...@gmail.com>
Date: Tue, 6 Nov 2007 12:45:35 +0000
Local: Tues, Nov 6 2007 7:45 am
Subject: Re: banging my head for last two days to find the blank line in RSS output
hi,

change:

<?xml version="1.0" encoding="UTF-8" ?>

to:

<?php echo '<?xml version="1.0" encoding="UTF-8" ?>'; ?>

hth

jon

On 06/11/2007, bingo <ragra...@gmail.com> wrote:

--

jon bennett
w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
AD7six  
View profile  
 More options Nov 6 2007, 7:47 am
From: AD7six <andydawso...@gmail.com>
Date: Tue, 06 Nov 2007 04:47:27 -0800
Local: Tues, Nov 6 2007 7:47 am
Subject: Re: banging my head for last two days to find the blank line in RSS output

On Nov 6, 1:37 pm, bingo <ragra...@gmail.com> wrote:

> hi Mike,

> you are right..I have short_open_tags on. But how does it matter?

because if you get a parse error, php will stop at that point issue an
error message and dump the buffer it has in memory. have you got as
output a full view with layout or just the view then?

in any event fixing a parseerror should be a no-brainer step forwards
(you can avoid it by doing <?php echo "<?xml ... ?> if you can't turn
off shorttags..

hth,

AD


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
AD7six  
View profile  
 More options Nov 6 2007, 7:48 am
From: AD7six <andydawso...@gmail.com>
Date: Tue, 06 Nov 2007 04:48:09 -0800
Local: Tues, Nov 6 2007 7:48 am
Subject: Re: banging my head for last two days to find the blank line in RSS output

On Nov 6, 1:13 pm, Mike Green <mik...@gmail.com> wrote:

> £50 says you have short_open_tags enabled in your php.ini

If I were a betting man... I wouldn't have taken that bet on :D

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bingo  
View profile  
 More options Nov 6 2007, 8:01 am
From: bingo <ragra...@gmail.com>
Date: Tue, 06 Nov 2007 13:01:56 -0000
Local: Tues, Nov 6 2007 8:01 am
Subject: Re: banging my head for last two days to find the blank line in RSS output
hi all,

I tried what Jon suggested. But still getting space before my xml
declaration :-( ...this is killing me...isn't there a good way to
debug this problem. Searching on the forum, I have realized that many
people struggle with this.

Regards,
Ritesh

On Nov 6, 7:48 am, AD7six <andydawso...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
AD7six  
View profile  
 More options Nov 6 2007, 10:07 am
From: AD7six <andydawso...@gmail.com>
Date: Tue, 06 Nov 2007 07:07:30 -0800
Local: Tues, Nov 6 2007 10:07 am
Subject: Re: banging my head for last two days to find the blank line in RSS output

On Nov 6, 2:01 pm, bingo <ragra...@gmail.com> wrote:

> hi all,

> I tried what Jon suggested. But still getting space before my xml
> declaration :-( ...this is killing me...isn't there a good way to
> debug this problem. Searching on the forum, I have realized that many
> people struggle with this.

"you could try issuing a header as the first line of your layout and
see where it complains output already
started. "

there are many threads because it's a common problem (or a common
mistake).

You'll find it in the end ;).

AD


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
seacloud9  
View profile  
 More options Nov 6 2007, 1:05 pm
From: seacloud9 <brendonsm...@seacloud9.org>
Date: Tue, 06 Nov 2007 10:05:59 -0800
Local: Tues, Nov 6 2007 1:05 pm
Subject: Re: banging my head for last two days to find the blank line in RSS output
I have run into the same issue.  It is a pain to fix but well worth
the benefits!

http://groups.google.com/group/cake-php/browse_thread/thread/20bc8af2...
my issue

My fix: http://i-create.org/UTF-8+Madness

Bake On!

On Nov 6, 9:07 am, AD7six <andydawso...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bingo  
View profile  
 More options Nov 6 2007, 2:54 pm
From: bingo <ragra...@gmail.com>
Date: Tue, 06 Nov 2007 19:54:13 -0000
Local: Tues, Nov 6 2007 2:54 pm
Subject: Re: banging my head for last two days to find the blank line in RSS output
hi AD7six,

I tried putting header in default layout for RSS, but didn't work. I
didn't recieve that output buffer already started at XYZ. The only
error that I am getting is "Invalid XML Declaration -  Line: 1
Character: 6". I also tried putting header command in controller
class, but that also didn't work. :-(

//views/layouts/rss/default.ctp
<?php echo header("Cache-Control: no-cache, must-revalidate"); ?>
<?php
echo $rss->header();
echo '<channel>';
echo '<link>', Router::url('/', true), '</link>';
echo '<language>en-us</language>';
echo '<pubDate>', date("D, j M Y H:i:s", gmmktime()) . ' GMT', '</
pubDate>';
echo '<generator>Memento</generator>';
echo '<managingEditor>ritesh.meme...@gmail.com</managingEditor>';
echo '<webMaster>ritesh.meme...@gmail.com</webMaster>';
echo '<docs>http://blogs.law.harvard.edu/tech/rss</docs>';
echo $content_for_layout;
echo '</channel>';
?>

This is frustrating :-(
isn't there any magic command that will automatically remove all the
trailing and leading spaces ?

Regards,
Ritesh

On Nov 6, 10:07 am, AD7six <andydawso...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
seacloud9  
View profile  
 More options Nov 6 2007, 4:00 pm
From: seacloud9 <brendonsm...@seacloud9.org>
Date: Tue, 06 Nov 2007 13:00:51 -0800
Local: Tues, Nov 6 2007 4:00 pm
Subject: Re: banging my head for last two days to find the blank line in RSS output
I have had this exact same problem it can hold you up for days..

Make sure you are using UTF-8 "BOMS".

Make sure tags in Model, Controller, and Views "<?
php"............................ "?>"
Have no spaces after or before them NONE.  I found one in the cake
folder in the app model.  You have six spaces this is literally the
cause of your frustrations.  You should check every model, view, and
controller..  It does suck but it is what is causing your problem.

On Nov 6, 1:54 pm, bingo <ragra...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bingo  
View profile  
 More options Nov 6 2007, 4:52 pm
From: bingo <ragra...@gmail.com>
Date: Tue, 06 Nov 2007 21:52:03 -0000
Local: Tues, Nov 6 2007 4:52 pm
Subject: Re: banging my head for last two days to find the blank line in RSS output
hi Seacloud9

I am not sure if I understand what do you mean by UTF-8 "BOMS". How
can verify that. I am using eclipse as my PHP Editor.

Regards,
Ritesh

On Nov 6, 4:00 pm, seacloud9 <brendonsm...@seacloud9.org> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
seacloud9  
View profile  
 More options Nov 6 2007, 6:14 pm
From: seacloud9 <brendonsm...@seacloud9.org>
Date: Tue, 06 Nov 2007 15:14:17 -0800
Local: Tues, Nov 6 2007 6:14 pm
Subject: Re: banging my head for last two days to find the blank line in RSS output
I don't know in eclipse my guess is it would be associated with your
overall preferences listed under encoding (google that) but you most
likely have space before and after your "<?php" .... "?>"  but do
check your model view controllers all of them.  It is a drag and it
did take me several days to do this myself but it was worth it.

On Nov 6, 3:52 pm, bingo <ragra...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
francky06l  
View profile  
 More options Nov 6 2007, 6:21 pm
From: francky06l <franckl...@gmail.com>
Date: Tue, 06 Nov 2007 23:21:37 -0000
Local: Tues, Nov 6 2007 6:21 pm
Subject: Re: banging my head for last two days to find the blank line in RSS output
BOMS, mean UTF-8 without BOM (byte order marker), this used under
windows to mark UTF-8 files (also UCS-2 etc...). Use an hexadecimal
editor and you will notice the 3 bytes marking the UTF-8 at the
beginning ..
Do not know if it's your problem, but quite classical under windows.
You can editor such as Notepad++ to check you file in hexa.
Hope this helps

On Nov 7, 12:14 am, seacloud9 <brendonsm...@seacloud9.org> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bingo  
View profile  
 More options Nov 6 2007, 10:09 pm
From: bingo <ragra...@gmail.com>
Date: Wed, 07 Nov 2007 03:09:13 -0000
Local: Tues, Nov 6 2007 10:09 pm
Subject: Re: banging my head for last two days to find the blank line in RSS output
hi AD7six, seacloud9, Jon, Mike, francky,

Thanks to all. Finally I was able to get rid of all my spaces. As many
of you expected, there were many leading and trailing spaces in my
code and once I removed all of them, everything worked like a charm.
The good news for other is that I wrote a small script that will
identify any trailing or leading spaces or new line in your PHP code
and will inform you about that file. Below is the script that does
this. Just provide the source location ($sourcepath) of your cakephp
application and it will recursively go through each file, checking if
there is any leading or trailing blank spaces.

<?php
/***********************
*@author: Ritesh Agrawal
*@description: Identifies php files that contain leading or trailing
spaces before or after PHP opening or closings tags
***********************/
//Set Source Path
$sourcepath = "D:/xampp/xampp/htdocs/memento";

//Regex Express to test leading and trailing spaces
define("PRE", "#^[\n\r|\n\r|\n|\r|\s]+<\?php#");
define("POST", "#\?>[\n\r|\n\r|\n|\r|\s]+$#");

//Clear the file Status Cache
clearstatcache();

//============ Code borrowed from php.net ===============
// Replace \ by / and remove the final / if any
$root = ereg_replace( "/$", "", ereg_replace( "[\\]", "/",
$sourcepath ));
// Touch all the files from the $root directory
if( false === m_walk_dir( $root, "check", true )) {
    echo "'{$root}' is not a valid directory\n";

}

// Walk a directory recursivelly, and apply a callback on each file
function m_walk_dir( $root, $callback, $recursive = true ) {
    $dh = @opendir( $root );
    if( false === $dh ) {
        return false;
    }
    while( $file = readdir( $dh )) {
        if( "." == $file || ".." == $file ){
            continue;
        }
        call_user_func( $callback, "{$root}/{$file}" );
        if( false !== $recursive && is_dir( "{$root}/{$file}" )) {
            m_walk_dir( "{$root}/{$file}", $callback, $recursive );
        }
    }
    closedir( $dh );
    return true;
}

//============== end ======================

//If file, checks whether there is any leading spaces before opening
PHP tag or
// trailing spaces after closing PHP tag
function check( $path ) {

    if( !is_dir( $path )) {
        $fh = file_get_contents($path);
         if(preg_match(PRE, $fh))
               echo $path. " -- contains leading spaces \n";
         if(preg_match(POST, $fh))
               echo $path . " -- contains trailing spaces \n";
    }

}

?>

On Nov 6, 6:21 pm, francky06l <franckl...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bingo  
View profile  
 More options Nov 6 2007, 10:40 pm
From: bingo <ragra...@gmail.com>
Date: Wed, 07 Nov 2007 03:40:37 -0000
Local: Tues, Nov 6 2007 10:40 pm
Subject: Re: banging my head for last two days to find the blank line in RSS output
or you can ready my blog :)
http://ragrawal.wordpress.com/2007/11/07/script-for-removing-blank-sp...

On Nov 6, 10:09 pm, bingo <ragra...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Samuel DeVore  
View profile  
 More options Nov 6 2007, 10:53 pm
From: "Samuel DeVore" <sdev...@gmail.com>
Date: Tue, 6 Nov 2007 20:53:34 -0700
Local: Tues, Nov 6 2007 10:53 pm
Subject: Re: banging my head for last two days to find the blank line in RSS output
On 11/6/07, bingo <ragra...@gmail.com> wrote:

So as a side note this would also be useful for all the people that
have problems with jpGraph, imagemagik, using gd to make images and
such as these issues can trip you up there as well

Sam D

--
(the old fart) the advice is free, the lack of crankiness will cost you

- its a fine line between a real question and an idiot

http://blog.samdevore.com/archives/2007/03/05/when-open-source-bugs-me/


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
seacloud9  
View profile  
 More options Nov 6 2007, 11:16 pm
From: seacloud9 <brendonsm...@seacloud9.org>
Date: Tue, 06 Nov 2007 20:16:52 -0800
Local: Tues, Nov 6 2007 11:16 pm
Subject: Re: banging my head for last two days to find the blank line in RSS output
Ritesh, thanks for the recipe it will help out my bakery.  Thanks:)

On Nov 6, 9:53 pm, "Samuel DeVore" <sdev...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
RichardAtHome  
View profile  
 More options Nov 7 2007, 5:26 am
From: RichardAtHome <richardath...@gmail.com>
Date: Wed, 07 Nov 2007 02:26:10 -0800
Local: Wed, Nov 7 2007 5:26 am
Subject: Re: banging my head for last two days to find the blank line in RSS output
Another useful tip to cut down on these kind of errors in future is:
The closing php tag '?>' is optional so if you omit it you will never
have any unwanted trailing spaces ;-)

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bingo  
View profile  
 More options Nov 7 2007, 6:21 am
From: bingo <ragra...@gmail.com>
Date: Wed, 07 Nov 2007 11:21:53 -0000
Local: Wed, Nov 7 2007 6:21 am
Subject: Re: banging my head for last two days to find the blank line in RSS output
hi Richard,

oh Cool, I didn't knew that :-p.

Regards,
Ritesh

On Nov 7, 5:26 am, RichardAtHome <richardath...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
MrTufty  
View profile  
 More options Nov 7 2007, 10:03 am
From: MrTufty <mrtu...@gmail.com>
Date: Wed, 07 Nov 2007 15:03:23 -0000
Local: Wed, Nov 7 2007 10:03 am
Subject: Re: banging my head for last two days to find the blank line in RSS output
Skipping the ?> is actually something the Zend Framework people
require if you submit code to them - it's in their coding style guide.
Seems to work, but I couldn't get the habit - I hated not having
balanced elements!

On Nov 7, 11:21 am, bingo <ragra...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google