sorry to post another problem so soon after my first one, but this has been bothering me for some time now.

Sometimes I can't get the echo funtion to work

I already use the $root succesfully in all the href and src attributes

last week I wanted to echo a var which returns the current schoolyear, thus this year being schoolyear 2006 - 2007

but the echo didn't seem to work unless I would put the script in the same file as the echo. However the same file contained numerous instances of <?php echo[/color $root ?> for links and img sources

Recommended Answers

All 7 Replies

I'm very confused by your question. Can you please provide an example of your specific code, what it currently does, and what you would like it to do.

I'm sorrr, I'l give you an example

some pages on the website contain dates and schoolyear references.
To make these dynamic I have already added a block of code to get the current schoolyear, and it sits in config.php:

// retrieve the current and previous year(four digits)
  $last_year = date( 'Y' );       //retrieve date of this year
  $last_year = ($last_year - 1);  //and reduce it by 1 to get the date of last year
  $this_year = date( 'Y' );       //retrieve date of this year
  $this_year = ($this_year - 0);
  $schoolyear = $last_year . " - " . $this_year; //defining the current school year

then I echo $schoolyear on the needed pages.

Sadly the echo didn't seem to work, even when I replaced $schoolyear with $root or another variable that is frequently used succesfully on many pages

the pages resides in a lv1 directory
config.php
|
-- nl

I'm sorrr, I'l give you an example

some pages on the website contain dates and schoolyear references.
To make these dynamic I have added a block of code to retrieve the ongoin schoolyear, and it sits in config.php:

// retrieve the current and previous year(four digits)
  $last_year = date( 'Y' );       //retrieve date of this year
  $last_year = ($last_year - 1);  //and reduce it by 1 to get the date of last year
  $this_year = date( 'Y' );       //retrieve date of this year
  $this_year = ($this_year - 0);
  $schoolyear = $last_year . " - " . $this_year; //defining the current school year

then I put

<?php echo $schoolyear ?>

on the needed pages.

Sadly echo didn't seem to work, even when I replaced $schoolyear with $root or any other variable that is frequently used succesfully on many pages

what's even more bizarre is that on another file, example.php I have put the same string.
(example.php is used for the navigation sidebar)

example.php:

// subscribtions for 2006 - 2007 are closed
<a href="<?php echo $root ?>index.php?name=...">subscribtions for <?php echo $schoolyear ?> are closed</a>

this works!

the tree:

/var/test- config.php
/var/test/common_files - example.php
/var/test/nl - page.php

So you are including this page in the other page? When you echo this variable on config.php, does it display then? Are you including this config.php page more than once?

may be you can use
<?echo $schoolyear;?>
or
<?=$schoolyear;?>

can you use

print("$schoolyear");

The site is deploying the same principle as inline frames

config.php:

foreach ($_GET as $key => $value) {	
    if ($key == 'dir') { 
      $dir = $value;
    }
    else {
      $var = $value;
    }
  }

index.php:

<?php Include 'config.php'; ?>
<!-- banner -->
<?php Include 'common_files/banner.php'; ?>
<!-- navcontainer -->
<?php Include 'common_files/navcontainer.php'; ?>
<!-- wrapper -->
<?php Include 'common_files/wrapper.php'; ?>

wrapper:

<!-- container -->
<?php include $root . 'nl/' . $dir . '/' . $var . '.php'; ?>
<!-- examplelist -->(quick links bar)			
<?php Include 'examplelist.php'; ?>
<!-- footer -->
<?php Include 'footer.php'; ?>

so eventually all files are gathered in index.php

I have put a small check subroutine on page.php, using IsSet to determine if $schoolyear is asigned, the check returned FALSE :confused:

since page.php is included in wrapper.php,which is included in index.php, it would seem that $schoolyear doesn't reach past wrapper.php, thus the limitations of include?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.