Error for undefined index

25-Nov-2013 19:40:22 America/Chicago] PHP Notice: Undefined index: HTTP in
/home/telco/public_html/yoursite.com/includes/0.sitelinks.php on line 2

The site is not https: but this is the template I was given. I removed the “s” but still the same error pops up.

any suggestions?

sitelinks file below


<?php
	$homePage = 'http'.(($_SERVER['HTTPS'])?'s':'').'://'.$_SERVER['SERVER_NAME'].'/';
	$home = $a;
	
    $suggestions = $a . 'suggestions/';
	$commentary     = $a . 'commentary/';

?

Where is the value $a defined?

I also tried to define that but didn’t edit the post.

$a should be the root domain if it is home, right?

The error is an undefined index value in the $_SERVER array();

Try this:



<?php 
  // INSERT DEBUG TESTS
     $test = isset( $_SERVER['HTTPS'] ) ? $_SERVER['HTTPS'] : 'Yes we have no https server :(';
     echo '<br />line: ' .__LINE__ .' - ' .$test;
     echo '<br />line: ' .__LINE__ .' - ' .$_SERVER['HTTPS'];       // I thnk this is the ERROR
     echo '<br />line: ' .__LINE__ .' - ' .$_SERVER['SERVER_NAME'];

  // show all $_SERVER items
     echo '<pre>';
       print_r($_SERVER);
     echo '<pre>';

  // EXISTING SCRIPT
     $homePage = 'http'.(($_SERVER['HTTPS'])?'s':'').'://'.$_SERVER['SERVER_NAME'].'/';

     $home = $a;
	
    $suggestions  = $a . 'suggestions/';
    $commentary = $a . 'commentary/';



line: 4 - Yes we have no https server :frowning:
line: 5 -
line: 6 - www dot yoursite dot com

it also gave me a long array about a page long.

OK Try this:



<?php

 // NEW SCRIPT
    $a = isset( $_SERVER['HTTPS'] ) ? 's' : ''; 
    $a = 'http' .$a. '://' .$_SERVER['SERVER_NAME'] .'/'; 
 
    $suggestions = $a .'suggestions/'; 
    $commentary  = $a .'commentary/';

    // SHOW VALUES 
    echo '<br />' .$a;
    echo '<br />' .$suggestions;
    echo '<br />' .$commentary;
    die;

 // OLD SCRIPT WITH ERRORS
     $homePage = 'http'.(($_SERVER['HTTPS'])?'s':'').'://'.$_SERVER['SERVER_NAME'].'/'; 

     $home = $a; 
     
    $suggestions  = $a . 'suggestions/'; 
    $commentary = $a . 'commentary/';



it also gave me a long array about a page long.

echo ‘<pre>’; print_r( $_SERVER ); echo ‘</pre>’; is useful for debugging

nothing in the array showed an error but I agree that it is something in that SERVER area

The array contains the status of your server.

The error that was being displayed was that you were trying to show the contents of an array server item which did not exist.

The error was eliminated by using isset($_SERVER[‘HTTPS’]) which tests if the variable exists.

I forgot to include the error setting and show errors:



<?php 
   // DEBUG and LOCLHOST ONLY
      error_reporting(-1);
      ini_set('display_errors', TRUE);


the developer told me to use the domain index.php in there but that gives same error.

Then he said it could be because of a server upgrade.

still the same error even with absolute path.

This is aggravating.

I would just use


$homePage = 'http://mydomainame.com/';    
$home = 'index.php';        
$suggestions = $a . 'suggestions/';   
$commentary     = $a . 'commentary/';

Although you shouldnt be getting that error and this is a workaround rather than a fix!