954,591 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

echo not working

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 [color=purple]<?php echo[/color $root ?> for links and img sources

¤| battousai |¤
Light Poster
37 posts since Sep 2006
Reputation Points: 17
Solved Threads: 1
 

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.

cscgal
The Queen of DaniWeb
Administrator
19,433 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 230
 

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

¤| battousai |¤
Light Poster
37 posts since Sep 2006
Reputation Points: 17
Solved Threads: 1
 

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.

Sadlyecho 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

¤| battousai |¤
Light Poster
37 posts since Sep 2006
Reputation Points: 17
Solved Threads: 1
 

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?

hradek
Newbie Poster
4 posts since Feb 2007
Reputation Points: 10
Solved Threads: 0
 

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

deni
Newbie Poster
2 posts since Feb 2007
Reputation Points: 10
Solved Threads: 0
 

can you use

print("$schoolyear");
crazynp
Junior Poster in Training
58 posts since Jan 2007
Reputation Points: 10
Solved Threads: 2
 

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, usingIsSet 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?

¤| battousai |¤
Light Poster
37 posts since Sep 2006
Reputation Points: 17
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You