ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Getting error with title tag of page. Error :: Message: Undefined offset: 1, Filename: libraries/Functions.php(650) : eval()'d code.

July 25, 2011 3:22am

Subscribe [3]
  • #1 / Jul 25, 2011 3:22am

    carswell

    16 posts

    Hello All,

    I hope all of are fine.
    I am facing error with title tag. The error was raised, when system administrator is logged in same browser. If system administrator is logged in with different browser then error is to be removed. Please see enclosed screen shot and error.

    <div [removed]>

    A PHP Error was encountered

    Severity: Notice
    Message:  Undefined offset:  1
    Filename: libraries/Functions.php(650) : eval()‘d code
    Line Number: 9

    </div><div [removed]>

    A PHP Error was encountered

    Severity: Notice
    Message:  Undefined offset:  1
    Filename: libraries/Functions.php(650) : eval()‘d code
    Line Number: 10

    </div>Carswell Distributing Co.  </title>

    Please assist me as per some for going ahead.

    Thanks & Regards,
    Prakash Vaniya.

  • #2 / Jul 25, 2011 6:35am

    Steven Grant

    894 posts

    what code are you using to call the title?

  • #3 / Jul 25, 2011 9:33am

    carswell

    16 posts

    Hi,

    Thanks for quick reply.
    I am using the code in title tag as per below.

    <?php $http_url = explode(‘site/’,$_SERVER[‘PHP_SELF’]);
    $title = ucfirst($http_url[1]);
    if(eregi(”/”,$http_url[1]))
    {
    $again_ex = explode("/",$http_url[1]);
    $title = ucfirst(eregi_replace("_"," ",$again_ex[0]));


    }
    if($title != “”)
    {
    if($again_ex[0] == 'brand_detail')
    { ?>
    Carswell Distributing Co. - {exp:channel:entries channel="Brand" }{title}  {/exp:channel:entries}
      <?php }
      else if($again_ex[0] == ‘employee-detail’)
      { ?>
    Carswell Distributing Co. - {exp:channel:entries channel="employee" }{title}  {/exp:channel:entries}
      <?php }
      else if($again_ex[0] == ‘case_studies_detail’)
      { ?>
    Carswell Distributing Co. - {exp:channel:entries channel="case_studies" }{title}  {/exp:channel:entries}
      <?php }
      else if($again_ex[0] == ‘state_detail’) { ?>
    Carswell Distributing Co. - {exp:channel:entries channel="state" }{title}  {/exp:channel:entries}
      <?php }
      else
      {
    echo 'Carswell Distributing Co. - '.$title;
    }
    }
    else
    {
    echo 'Carswell Distributing Co. '.$title;
    }
    ?>

    Brand is weblog, i have created.

    Thanks & regard,
    Prakash Vaniya.

  • #4 / Jul 25, 2011 9:42am

    Steven Grant

    894 posts

    a weblog or a channel? Are you using EE1 or EE2?

  • #5 / Jul 25, 2011 9:50am

    carswell

    16 posts

    I am using EE2.
    Brand, employee, case_studies and state are channel.

    Please let me know what’s going wrong.

    Thans & Regards,
    Prakash Vaniya.

  • #6 / Jul 25, 2011 10:24am

    Steven Grant

    894 posts

    wow - why all the PHP code? use segment conditionals instead and work from there.

  • #7 / Jul 25, 2011 8:40pm

    the3mus1can

    426 posts

    First, only seeing error messages when logged in as a super admin is the default behavior.  This is for “security” reasons.  If you are not logged in then EE suppresses the error messages. 

    Below I have pointed out the problems with the code.

    <?php 
      $http_url = explode(‘site/’,$_SERVER[‘PHP_SELF’]);
      $title = ucfirst($http_url[1]);  <----- problem
      if(eregi(”/”,$http_url[1])) <----- problem
      {
        $again_ex = explode(”/”,$http_url[1]); 
        $title =  ucfirst(eregi_replace(“_”,” ”,$again_ex[0]));
      }
    ?>

    You are not checking for the existence of that index in the array after calling explode(‘site/’,$_SERVER[‘PHP_SELF’]);  If you are the home page then more then likely the result of explode(‘site/’,$_SERVER[‘PHP_SELF’] will be array(0 => “/index.php”);  Notice there is no index 1. Below should eliminate the error messages:

    <?php 
    
      $http_url = explode(‘site/’,$_SERVER[‘PHP_SELF’]);
      
      $title = '';
      
      if (isset($http_url[1]))
      {
        $title = ucfirst($http_url[1]);
        if(eregi(”/”,$http_url[1]))
        {
          $again_ex = explode(”/”,$http_url[1]); 
          $title =  ucfirst(eregi_replace(“_”,” ”,$again_ex[0]));
        }
      }  
    
    ?>

    However, it would be better to use URL segment variables (http://ellislab.com/expressionengine/user-guide/templates/globals/url_segments.html).

  • #8 / Jul 26, 2011 3:05am

    carswell

    16 posts

    Hi the3mus1can,

    Thanks for assisting and better service.
    I have used the segment as per below for this issue. Now it is working well.

    {if segment_2 == 'brand_detail'}
        Carswell Distributing Co. - {exp:channel:entries channel="Brand" }{title}{/exp:channel:entries}
    {if:elseif segment_2 == 'employee-detail'}
        Carswell Distributing Co. - {exp:channel:entries channel="employee" }{title}{/exp:channel:entries}
    {if:elseif segment_2 == 'case_studies_detail'}
        Carswell Distributing Co. - {exp:channel:entries channel="case_studies" }{title}{/exp:channel:entries}
    {if:elseif segment_2 == 'state_detail'}
        Carswell Distributing Co. - {exp:channel:entries channel="state" }{title}{/exp:channel:entries}
    {if:elseif segment_2 == ''}
        Carswell Distributing Co.
    {if:else}
        Carswell Distributing Co. - <? echo ucfirst(eregi_replace("_"," ",'{segment_2}')); ?>
    {/if}

    I still use the php code in else condition. Can i use the any one expression engine function for first letter capital and replace underscore with space?

    Thanks again for better service.

    Thanks & Regards,
    Prakash Vaniya.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases