[SOLVED] include(); places unaccounted for 1

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

[SOLVED] include(); places unaccounted for 1

Post by $var »

i'm using a variable to select an include path.
however, i am experiencing strangeness.


the method calls the include alright, but there is a random "1" appearing in the HTML output after the include ends.
i tested for errors by posting an empty include file and the "1" prevails!

nothing else echos!
the only thing that i can do to get rid of it is comment out the BEGIN EVENTS section.

WTF anyone?

Code: Select all

$unitID = $_GET['unitID']
   if(!empty($unitID)) {
      $getEventDiv = "/includes/div/events/eventsDivUnitList.inc.php";
   }

Code: Select all

<div id="col2">
		<!-- BEGIN EVENTS-->
			[php]<? echo include($_SERVER['DOCUMENT_ROOT']."$getEventDiv"); ?>[/php]
		<!-- END EVENTS-->
  </div>
Last edited by $var on Fri Apr 20, 2007 11:16 am, edited 1 time in total.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

include() returns TRUE on success & FALSE on failure. You're echoing include(), which will interpret the TRUE as a 1, & echo it. Remove the echo statement - it's not necessary for the purpose of displaying what's in the include file.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

Post by $var »

THANK YOU PICKLE!
Post Reply