Page 1 of 1

[SOLVED] include(); places unaccounted for 1

Posted: Fri Apr 20, 2007 10:47 am
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>

Posted: Fri Apr 20, 2007 11:03 am
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.

Posted: Fri Apr 20, 2007 11:16 am
by $var
THANK YOU PICKLE!