Required or included files listed at top of screen?!
Moderator: General Moderators
Required or included files listed at top of screen?!
Can anybody tell me why files I require or include are being listed at the top of my screens? I am working in version 3.23.43.
Version and puzzlement
Oh, the version is 4.1.2, but that's a puzzlement, because I seem to be failing on v. 4 added functions, like require_once and session_register. This is my first website attempted with PHP, and I'm starting with code from the source CD of a book, PHP and MySQL Web Development (Chapter 24) and trying to get the code to run so I can then cannibalize it.
When I changed require_once to require (and then to include), or commented it out in other places, and commented out the session_register statement, I got further into the code, (though I realized I would have to make adjustments for what I'd changed). When I saw these were both V. 4 functions and saw the 3.23.43 when I got into MySQL (duh), I thought I had the answer.
I don't know what code's putting the unwanted display on the screen (//login.php //bookmark_fns.php //data_valid_fns.php //db_fns.php //user_auth_fns.php //output_fns.php //url_fns.php), but I noticed the two places I've seen it occur are places where where bookmark_fns.php is required and then requires the subsequently named programs. In both cases the first program named is the one with that requires bookmark_fns.php. Login.php is run from a button on my index.htm.
Here's the login.php code:
//login.php
<?
// Changed from require-once pending replacement w/v. 3 code and to include due to printing at top of screen.
include("bookmark_fns.php");
do_html_header("");
display_site_info();
display_login_form();
do_html_footer();
?>
Here's the bookmark_fns.php code:
//bookmark_fns.php
<?
// We can include this file in all our files
// this way, every file will contain all our functions
// Below is changed from require_once replacement w/v. 3 code--require resulted in putting list at top of including screen
include("data_valid_fns.php");
include("db_fns.php");
include("user_auth_fns.php");
include("output_fns.php");
include("url_fns.php");
?>
I added the name at the top in both cases and the code pertaining to require_once.
The site is worldidealsinaction.org. I was putting it up in html, via FrontPage, but decided it was too complex to do that way, so I decided I'd better hurry up and get going with PHP and MySQL, which I've been studying for a few months.
When I changed require_once to require (and then to include), or commented it out in other places, and commented out the session_register statement, I got further into the code, (though I realized I would have to make adjustments for what I'd changed). When I saw these were both V. 4 functions and saw the 3.23.43 when I got into MySQL (duh), I thought I had the answer.
I don't know what code's putting the unwanted display on the screen (//login.php //bookmark_fns.php //data_valid_fns.php //db_fns.php //user_auth_fns.php //output_fns.php //url_fns.php), but I noticed the two places I've seen it occur are places where where bookmark_fns.php is required and then requires the subsequently named programs. In both cases the first program named is the one with that requires bookmark_fns.php. Login.php is run from a button on my index.htm.
Here's the login.php code:
//login.php
<?
// Changed from require-once pending replacement w/v. 3 code and to include due to printing at top of screen.
include("bookmark_fns.php");
do_html_header("");
display_site_info();
display_login_form();
do_html_footer();
?>
Here's the bookmark_fns.php code:
//bookmark_fns.php
<?
// We can include this file in all our files
// this way, every file will contain all our functions
// Below is changed from require_once replacement w/v. 3 code--require resulted in putting list at top of including screen
include("data_valid_fns.php");
include("db_fns.php");
include("user_auth_fns.php");
include("output_fns.php");
include("url_fns.php");
?>
I added the name at the top in both cases and the code pertaining to require_once.
The site is worldidealsinaction.org. I was putting it up in html, via FrontPage, but decided it was too complex to do that way, so I decided I'd better hurry up and get going with PHP and MySQL, which I've been studying for a few months.
hmmm..I can't see why the filenames are printed.
I suggest you start again (if you haven't changed to much useful things yet) with the original code.
Maybe (as long as you're coding) you should set
Use html-comments to find the place where the output is generated, i.e.This may conflict with session_start(), or header(...) in other parts of the scripts, see also http://www.devnetwork.net/forums/viewtopic.php?t=1157
I suggest you start again (if you haven't changed to much useful things yet) with the original code.
Maybe (as long as you're coding) you should set
in your php.ini. But personally I don't really like "display_errors = On" and prefer watching the error.log-file.error_reporting = E_ALL
display_errors = On
Use html-comments to find the place where the output is generated, i.e.
Code: Select all
<?php
print('<!-- including data_valid_fns.php -->');
include("data_valid_fns.php");
print('<!-- including db_fns.php -->');
include("db_fns.php");
print('<!-- including user_auth_fns.php -->');
include("user_auth_fns.php");
print('<!-- including output_fns.php -->');
include("output_fns.php");
print('<!-- including url_fns.php -->');
include("url_fns.php");
print('<!-- includes done -->');
...
?>Have you set the path of where to store sessions in php.ini
Code: Select all
session_save_path = DIRECTORYHmm, scratched my head for a moment here... but I think I see what is happening. Your PHP comment lines are prefixed by // - this will comment them out as long as they are in PHP blocks, i.e. in between <? ?>. But they aren't! Try moving them to inside the <? ?> otherwise they would need to be commented out inside <! -- --> (HTML commenting).
At the moment it seems to me that these "comments" are just being echoed to the browser. Hope it helps!
At the moment it seems to me that these "comments" are just being echoed to the browser. Hope it helps!