Hello I was hoping I can get some help with this.
I have this file that works perfectly online but when I test it on my local Mac OSX Apache PHP4 installation I get this error:

Fatal error: Call to undefined function: chaindlk_sidebars()

The undefined function is as follows:

function ChainDLK_sidebars()
{
global $general_pics;
global $interview_pics;
global $article_pics;
global $ads_pics;
global $form_field_size;
global $_SERVER['DOCUMENT_ROOT'];

// COPY THIS INTO ARRAY WHEN GOING LIVE *******************************************
//		$_SERVER['DOCUMENT_ROOT']."/sidebars",

    $include_dirs = Array(
	$_SERVER['DOCUMENT_ROOT']."/interviews/sidebars"
    );

    $random_dir = array_rand($include_dirs);

    $dir=opendir($include_dirs[$random_dir]);

$available_files=array();

while($file=readdir($dir)) {
  if(substr($file, 0, 3) == "HL-" and substr($file, -4) == ".inc")

$available_files[]=$file;
}
$selected_files = array_rand($available_files,3);

	foreach($selected_files as $file)
	{
		if (substr($available_files[$file], 0, 12) == "HL-interview") {
		  box_up();
		  include($_SERVER['DOCUMENT_ROOT'].'/interviews/sidebars/'.$available_files[$file]);
		  box_down();
		}
		else if (substr($available_files[$file], 0, 10) == "HL-SIDEBOX") {
		  box_up();
		  include($_SERVER['DOCUMENT_ROOT'].'/sidebars/'.$available_files[$file]);
		  box_down();
		}

	}
}

Like I said, this function works perfectly when uploaded to my remote server via ftp but for some reason fails locally. Do you know why?

    I had thought about that but it's not that because the function is called with the right case from the index file, for some reason the error returns the function in all lowercase but when it is called it is called with the correct case... any other ideas?

      IFAIK, functions are case insensitive.

      I'm stupem on this one. It has to be something simple. Is this function declared in the page or in an include? Spelled right?

        there can't be a mispelling because these are files that work flawlessly online and just don't work offline... it must be something local...

        I can tell you this:

        index.php is this:

        <!--
        <?PHP include_once($_SERVER['DOCUMENT_ROOT'].'/chaindlk.php'); ?>
        //-->
        <html>
        <head>
        <title>CHAIN D.L.K. | Archives</title>
        <? ChainDLK_head_tag(); ?>
        </head>
        <body>
        
        <? ChainDLK_head_nav(); ?>
        
        <table width="100%" border="0" cellspacing="0" cellpadding="5" name="MAIN_BODY_TABLE">
          <tr valign="top"> 
            <td> 
                <? ChainDLK_sidebars(); ?>
            </td>
            <td width="100%">
              <? include('archives.inc'); ?>
            </td>
            <td> 
                <? ChainDLK_sidebars(); ?>
            </td>
          </tr>
        </table>
        <br>
        <?
        	ChainDLK_footer();
        	include($_SERVER['DOCUMENT_ROOT'].'/counters/mpcount/mpcount.php3');
        ?>
        </body>
        </html>

        and the file chaindlk.php that contains all these functions is simply a bunch of functions among which the one I posted already.

        Interestingly the function ChainDLK_head_tag(); (which is called before the one that returns an error) works like a charm.

          echo your $_SERVER['DOCUMENT_ROOT'] variable. Perhaps you don't have it set correctly on your local server...

            if I didn't have it set correctly the file chaindlk.php wouldn't be included at all, instead it is included and is partly processed (ie the function ChainDLK_head_tag(); works and so does ChainDLK_head_nav(); but when it gets to ChainDLK_sidebars(); it doesn't work - all functions are inside chaindlk.php)

              Does anybody have any ideas about this?

                Can you just have the ChainDLK_sidebars function echo text to make sure the function is loading? Once you do that, go through and echo out all of your variables inside the function to make sure everything is set correctly.

                Programming is a tricky thing. I suggest you stop making assumptions like "if I didn't have it set correctly..." The fact is, it's not working, and you can't take ANYTHING for granted. Even if you think something can't possibly be causing the problem, test it, so that you can definitely eliminate it as a possibility.

                Let me give you a couple of quotes from Sir Arthur Conan Doyle:

                When you have eliminated the impossible, that which remains, however improbable, must be the truth.

                It is a capital mistake to theorize before one has data. Insensibly one begins to twist facts to suit theories, instead of theories to suit facts.

                Good Luck.

                  Nice quote ;-)
                  I'll try all of that. It's a good approach that I usually use when troubleshooting, I just thought it this case (***) you guys might see something I can't see...

                  *** when I say "in this case" I mean: it works online but doesn't offline

                    If the code works, then the difference between the cases is your servers. There is something set differently that is causing the problem. Checking all of your variables may reveal the culprit. I wouldn't even be surprised if it was something as benign as "register_globals" being turned on... LOL

                      See that's what I meant when I said you might see something I don't... I alredy know that register_globals is ON on one server and OFF on another but I thought that only the way I refer to $DOCUMENT_ROOT variable would be affected by that... Is there any other thing in my code that would need to be addressed differently for the two settings of register_globals?

                        It's hard to say without seeing more code... it could be in your includes, or it could be one of the global variables you declare at the start of your function. I'd start with those first -- echo them out and see if they are the values you are expecting.

                        I know this doesn't solve your current problem, but I strongly suggest that for any code you write or change from this point forward, always assume that register_globals is turned off. That way your variable will always act the way you expect, regardless of the server you are on.

                        If you (or anyone reading this) is not familiar with the register_globals issues, read about it here.

                          Write a Reply...