Error

Hey folks,
i m working on someone else project and i am having problem. if u visit this page u wuld see rss feeds. when i put them within the <li> under the news i.e

<?php include('feeder.php');?>

it gives a unexpected error of T_STRING. what should i?

The error is probably not on that line. It could be that there was another previous line that isn’t ended properly. Is there more code prior to this line that you could show us?

well this is preety long page and a bad coding but i paste it all and highlighted where i need to put the page (its in bold)

<?php
///////////////////////////////////////////////////////////////////
    function wp_titlenew($sep = '&raquo;', $display , $seplocation = '') {
    global $wpdb, $wp_locale, $wp_query;

    $cat = get_query_var('cat');
    $tag = get_query_var('tag_id');
    $category_name = get_query_var('category_name');
    $author = get_query_var('author');
    $author_name = get_query_var('author_name');
    $m = get_query_var('m');
    $year = get_query_var('year');
    $monthnum = get_query_var('monthnum');
    $day = get_query_var('day');
    $search = get_query_var('s');
    $title = '';

    // If there is a post
    if ( is_single() || ( is_home() && !is_front_page() ) || ( is_page() && !is_front_page() ) ) {
        $post = $wp_query->get_queried_object();
        $title = apply_filters( 'single_post_title', $post->post_title );
    }


     // Determines position of the separator and direction of the breadcrumb
    
    $title = apply_filters('wp_title', $title, $sep, $seplocation);

    // Send it out
    return $title;

} 
///////////////////////////////////////////////////////////
require_once (get_template_directory() . '/classes/WPage.php');

add_editor_style();
add_theme_support('post-thumbnails');
add_theme_support('automatic-feed-links');

if (function_exists('register_nav_menus')) {
    register_nav_menus(array(
        'header-menu' => 'Header Menu',
    ));
}

if (function_exists('register_sidebar')) {
    register_sidebar(array(
        'name' => 'sidebar',
        'before_widget' => '<div id="%1$s" class="widget %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h3>',
        'after_title' => '</h3>',
    ));
}

add_custom_background();

if (!isset($content_width)) $content_width = 500; // The maximum image size in pixels - adjust to suit.

if (!function_exists('display_page')) {
  function display_page () {
    global $wpage;
    $wpage->doctype('xhtml', 'strict');
    $wpage->link(array('../css/bp.screen.css', 'jquery.js'), true);
    $wpage->css('../css/bp.print.css', 'print');
    $wpage->css('../css/bp.ie.css', '', 'lt IE 7');
    $html = '';
    
    /*
    // Blueprint Template Example
    require_once (get_template_directory() . '/classes/Blueprint.php');
    $bp = new Blueprint(24);
    $html .= $bp->page();
    $html .= $bp->row($wpage->get('header')); 
    $html .= $bp->swap(19, 5, $wpage->get('content'), $wpage->get('sidebar'));
    $html .= $bp->row($wpage->get('footer')); 
    $html .= $bp->close(); 
    unset ($bp);
    */
    
    // YUI Template Example
    require_once (get_template_directory() . '/classes/YUI.php');
    $wpage->link(array('../css/bp.screen.css', '../css/bp.yui.css', 'jquery.js'), true);
    $yui = new YUI('950');
    $html .= $yui->page('left', 180, $wpage->get('sidebar')); 
    $html .= $yui->header($wpage->get('header')); 
    $html .= $yui->body($wpage->get('content')); 
    
    
    //if($_REQUEST['page_id']==40)
    if(is_front_page()==true)
    ////////////////////////////////////////////////////////////
    {

global $wpdb;
$no_posts = 2;
$before = '<li >';
$after = '</li>';
$hide_pass_post = true;
$skip_posts = 0;
$show_excerpts = true;
$include_pages = false;

    $time_difference = get_settings( 'gmt_offset' );
    $now = gmdate( "Y-m-d H:i:s", time() );
    $request = "SELECT ID, post_title, post_excerpt FROM $wpdb->posts WHERE post_status = 'publish' ";
    if ( $hide_pass_post )
        $request .= "AND post_password ='' ";
    if ( $include_pages )
        $request .= "AND (post_type='post' OR post_type='page') ";
    else
        $request .= "AND post_type='post' ";
    $request .= "AND post_date_gmt < '$now' ORDER BY post_date DESC LIMIT $skip_posts, $no_posts";
    $posts = $wpdb->get_results( $request );
    $output = '';
    $output.='<ul class="recentnews">';
    if ( $posts ) {
        foreach ( $posts as $post ) {
            $post_title = $post->post_title;
            $permalink = get_permalink( $post->ID );
            
            $output .= $before . '<a href="' . esc_url( $permalink ) . '" rel="bookmark" title="Permanent Link: ' . esc_attr( $post_title ) . '">' . esc_html( $post_title ) . '</a>';
            if ( $show_excerpts ) {
                $post_excerpt = esc_html( $post->post_excerpt );
                $output.= '<br />' .substr ( $post_excerpt , 0 ,80).'...<a href="'.esc_url( $permalink ).'"><span id="readmore">Read more</span></a>';
            }
            $output .= $after;
        }
        $output .='</ul>';
    } else {
        $output .= $before . "None found" . $after;
    }
  // echo $output;
//////////////////////////////////////////////////////////////
$valueone="if(document.getElementById('ea').value=='') {alert('Please Insert Valid Email ID'); return false}";

    $html .='<div class="outerhomedown">
    <div class="forhomecolum2">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><h4>Sign Up For Our Group Newsletter</h4></td>
  </tr>
  <tr>
    <td><span style="font-size:11px">Enter email to receive news and information updates</span></br><form name="ccoptin" onsubmit="'.$valueone.'" action="http://visitor.r20.constantcontact.com/d.jsp" target="_blank" method="post" style="margin-bottom:3;">
<font style="font-weight: bold; font-family:Arial; font-size:16px; color:#006699;"></font>
<input id="ea" type="text" name="ea" style="width:200px;" value="" style="font-family:Verdana,Geneva,Arial,Helvetica,sans-serif; font-size:10px; border:1px solid #999999;"> <input type="submit" name="go" value="GO"  style="text-align:center;width:40px;" class="submit"  style="font-family:Verdana,Arial,Helvetica,sans-serif; font-size:10px;">
<input type="hidden" name="llr" value="wvir9bfab">
<input type="hidden" name="m" value="1104941720246">
<input type="hidden" name="p" value="oi">
</form></td>
  </tr>
  <tr>
    <td class="newstopborder" ><h1>News</h1></td>
  </tr>
   <tr>
    <td><ul class="recentnews">[B]<li><?php echo ('feeder.php');?></li>[/B]
  
  
<li ><a href="http://www.mentors.ie/blog/seizing-competitor-hr-assets/" rel="bookmark" title="Permanent Link: First Post">Seizing Competitor HR Assets</a><br />One of the sad truths in todays economy is that a large number of industries are  not going to weather the storm....<a href="http://www.mentors.ie/blog/seizing-competitor-hr-assets/"><span id="readmore">Read more</span></a></li>
</ul>
</td>
  </tr>
</table>
</div><div class="homedown">
<h1>Welcome To Leading Edge Group</h1>
<p>Leading Edge Group owns and operates profession services subsidiaries in the ireland market.
our performance is driven by our name - we seek to be at the leading edge of innovation in our areas of operation.</p><img src="wp-content/uploads/2011/03/sign.jpg" hspace="10px" align="right" alt="Sign" width="148" height="112" /></div>
</div>';}
        
    $html .= $yui->footer($wpage->get('footer')); 
    $html .= $yui->close(); 
    unset ($yui); 
    
    
    echo $wpage->display($html);
    ob_end_flush();
  }
}

?>




<?php
/* Breadcrumb */

function phi_breadcrumbs() {

    if(get_option('phi_breadcrumb')==false){
    echo '<div id="breadcrumb">';

     if(get_option(phi_breadcrumb)==false){
    $delimiter = ' &raquo; ';
    $home_name = get_option(phi_trans_home);

    if ($home_name){

    $name = $home_name;    

    }

    else{

    $name = 'Home'; //text for a 'Home' link

    }

    if ( !is_home() || !is_front_page() || is_paged() ) {

        global $post;

        $home = get_bloginfo('url');

        echo 'You are here: <a href="' . $home . '">' . $name . '</a> ' . $delimiter . ' ';
        if ( is_category() ) {
            global $wp_query;
            $cat_obj = $wp_query->get_queried_object();
            $thisCat = $cat_obj->term_id;
            $thisCat = get_category($thisCat);
            $parentCat = get_category($thisCat->parent);
            if ($thisCat->parent != 0) echo(get_category_parents($parentCat, TRUE, ' ' . $delimiter . ' '));
            echo 'Archive by category '';
            single_cat_title();
            echo ''';
         } elseif ( is_day() ) {
        echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
        echo '<a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('F') . '</a> ' . $delimiter . ' ';
        echo get_the_time('d');
        } elseif ( is_month() ) {
        echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
        echo get_the_time('F');
        } elseif ( is_year() ) {
        echo get_the_time('Y');
        } elseif ( is_single() ) {
            $cat = get_the_category(); $cat = $cat[0];
            if($cat!=''){
            echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
            }
            the_title();
        } 
        elseif ( is_page() && !$post->post_parent ) {
            the_title();
        } elseif ( is_page() && $post->post_parent ) {
            $parent_id  = $post->post_parent;
            $breadcrumbs = array();
            while ($parent_id) {
                $page = get_page($parent_id);
                $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
                $parent_id  = $page->post_parent;
            }
            $breadcrumbs = array_reverse($breadcrumbs);
            foreach ($breadcrumbs as $crumb) echo $crumb . ' ' . $delimiter . ' ';
            the_title();
         } elseif ( is_search() ) {
            echo 'Search results for '' . get_search_query() . ''';
        } elseif ( is_tag() ) {
            echo 'Posts tagged '';
            single_tag_title();
            echo ''';
        } elseif ( is_author() ) {
             global $author;
            $userdata = get_userdata($author);
            echo 'Articles posted by ' . $userdata->display_name;
        }
        if ( get_query_var('paged') ) {

            if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' (';

            echo __('Page') . ' ' . get_query_var('paged');

            if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')';
        }
    }
}
echo '</div>';
}
}
?>

and i get this error

Parse error: syntax error, unexpected T_STRING

edit: the line where this error comes has include feeder.php

I don’t see include(‘feeder.php’);, but I do see this line:

<td><ul class="recentnews">[B]<li><?php echo ('feeder.php');?></li>[/B]

This line should be something like this:


<td><ul class="recentnews">[B]<li>';

include ('feeder.php');

$html .= '</li>[/B]

I don’t know what is in feeder.php, but this may not work the way you want it to as it is set up, but it will definitely not do what you want it to the way it is.

You also have two sets of lines with too many single quotes and that is going to give you errors:



echo 'Archive by category '';
            single_cat_title();
            echo ''';

echo 'Search results for '' . get_search_query() . ''';

echo 'Posts tagged '';
            single_tag_title();
            echo ''';

These should be (and they are separate in your code):


echo 'Archive by category ';
            single_cat_title();
            echo '';

echo 'Search results for ' . get_search_query();

echo 'Posts tagged ';
            single_tag_title();
            echo '';

Look carefully at number of single quotes in each group. I don’t know why you have echo ‘’; at all, but if you are holding that space to put something in later, fine. Otherwise, you should drop it altogether.

Make those changes and try it again.

feeder.php is a file that calls on to rss feed. i did got it working but if u see.its loading on top of page.where as i want it under news on the right side.
as for quotes. this is pretty nasty coding someone did and i have no time to clean it but to make the upper discussed problem solved.

If feeder.php simply echos its contents to the page, you can alter it to store it in a variable and substitute that variable into your content like this:


<td><ul class="recentnews">[B]<li>' . $variableYouCreateInFeeder . '</li>[/B] 

Otherwise you are going to have to alter your script to wait on the include until you are actually putting your info on the screen.

how do i call a page n store its content to a variable? i mean i know how to call variable but how to store page content in that variable?

Well, if the page has everything echo’d or print’d to the page, then you would just change that to be like your $html variable. Example:

echo’d:


echo 'These are the contents of feeder.php';

switch to a variable:


$variableYouCreateInFeeder = 'These are the contents of feeder.php';

Then, where ever you want to put it in your script, like I showed above.

Hopefully, it will be simple and straight forward, but that is not often the case. There could be multiple echo calls, or it could be stored in a function, which makes it a bit more complex, but just as doable.

i wouldn’t go for that approach now as i can’t understand now (all slow now) though coz i have a problem that my content of feeder isn’t being displayed where i wanted i.e under the news

can u tell me what are u recommending. like echo page in variable and calling it. ?

Well, without knowing exactly what $wpage->display() does, I don’t think I can just rewrite your code posted here to make it the way you want, but if you can post feeder.php, I can probably rework that without much trouble to show you what I mean.

here is feeder.php content

<?php if (function_exists('fetch_feed')) { ?>
               
                <?php include_once(ABSPATH . WPINC . '/feed.php');
               
                      $feed = fetch_feed('http://leading.microarts.biz/myrss.xml');
               
                      $limit = $feed->get_item_quantity(2);
                   
                      $items = $feed->get_items(0, $limit);
 } ?>

          <?php if (!$items) {
                       
                        echo "problem";
                       
                    } else {
                       
                        // everything's cool
                       
                        foreach ($items as $item) { ?>
                           
                            <div class="sidebar-post">
                                <p class="date"><?php echo $item->get_date('F j, Y'); ?></p>
                                <h5><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h5>
                                <p><?php echo $item->get_content(); ?></p>
                            </div>
                       
                    <?php }
                   
                    } ?>

i just wanna align the text to the correct place.instead of it displaying on top of page

This should do that for you. Back up your feeder.php to another file, i.e. feeder.php.bak and then substitute this in for it:


<?php 
$feederContent = '';

if (function_exists('fetch_feed')) { 

	include_once(ABSPATH . WPINC . '/feed.php');

   $feed = fetch_feed('http://leading.microarts.biz/myrss.xml');

   $limit = $feed->get_item_quantity(2);

   $items = $feed->get_items(0, $limit);

} 
 
if (!$items) {

   echo "problem";

} 

else {

   // everything's cool

   foreach ($items as $item) {

      $feederContent .= '<div class="sidebar-post">
         <p class="date">' . $item->get_date('F j, Y') . '</p>
         <h5><a href="' . $item->get_permalink() . '">' . $item->get_title() . '</a></h5>
         <p>' . $item->get_content() . '</p>
         </div>';

   }

} 
?>

Then back in your originally posted script, find this line:


<td><ul class="recentnews">[B]<li><?php echo ('feeder.php');?></li>[/B]

and you can now replace it with this line:


<td><ul class="recentnews">[B]<li>' . $feederContents . '</li>[/B]

and you can add this line:


include('feeder.php');

somewhere, like right before this line:


$html .='<div class="outerhomedown">

That should do it.

not any error is shown but that is also gone (not being displayed)
Edit : you mentioned $feederContents . doesn’t $feederContents need to be declared?

Sorry. I didn’t write a line correctly for you:

<td><ul class=“recentnews”><li>’ . $feederContents . '</li>

should be:

<td><ul class=“recentnews”><li>’ . $feederContent . '</li>

I misnamed the variable in the first page.

Your a life saver Cute Tink. although i need another favor. i need to break the style after one rss post. like there are 2 post showing. there style is declared in css but how i apply it over here so each post get own style.
btw Thanks again and Thanks al ot!

Not sure what you mean by that. Could you be more specific about what you want to change about it?

well now its displaying it in one li. i want each post to be displayed in separate li

Ok. Two more changes to make. First, back to this line:

<td><ul class=“recentnews”><li>’ . $feederContent . '</li>

Change it to this:

<td><ul class=“recentnews”>’ . $feederContent . ’

Then in the feeder.php file:


$feederContent .= '<div class="sidebar-post">
         <p class="date">' . $item->get_date('F j, Y') . '</p>
         <h5><a href="' . $item->get_permalink() . '">' . $item->get_title() . '</a></h5>
         <p>' . $item->get_content() . '</p>
         </div>';

Change it to:


$feederContent .= '<li><div class="sidebar-post">
         <p class="date">' . $item->get_date('F j, Y') . '</p>
         <h5><a href="' . $item->get_permalink() . '">' . $item->get_title() . '</a></h5>
         <p>' . $item->get_content() . '</p>
         </div></li>';