Page 1 of 1

Required or included files listed at top of screen?!

Posted: Mon Sep 02, 2002 5:51 pm
by davidmcc
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.

Posted: Mon Sep 02, 2002 7:28 pm
by volka
can we see the (relevant part of the) script?
and 3.23.43 is more likely your mysql-version ;)

Version and puzzlement

Posted: Mon Sep 02, 2002 8:46 pm
by davidmcc
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.

Posted: Mon Sep 02, 2002 9:38 pm
by volka
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
error_reporting = E_ALL
display_errors = On
in your php.ini. But personally I don't really like "display_errors = On" and prefer watching the error.log-file.

Use html-comments to find the place where the output is generated, i.e.

Code: Select all

&lt;?php
print('&lt;!-- including data_valid_fns.php --&gt;');
include("data_valid_fns.php"); 
print('&lt;!-- including  db_fns.php --&gt;');
include("db_fns.php"); 
print('&lt;!-- including user_auth_fns.php --&gt;');
include("user_auth_fns.php"); 
print('&lt;!-- including output_fns.php --&gt;');
include("output_fns.php"); 
print('&lt;!-- including url_fns.php --&gt;');
include("url_fns.php"); 
print('&lt;!-- includes done --&gt;');
...
?&gt;
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

Posted: Tue Sep 03, 2002 1:00 am
by Takuma
Have you set the path of where to store sessions in php.ini

Code: Select all

session_save_path = DIRECTORY

Posted: Tue Sep 03, 2002 4:47 am
by pat001
Hmm, 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!

Thanks

Posted: Tue Sep 03, 2002 9:03 pm
by davidmcc
Thanks to those who volunteered help. The problems turned out to be using <? instead of <?php (required for some reason in my environment) and putting the // for comments outside the <?php and ?>.

Posted: Wed Sep 04, 2002 12:02 am
by volka
pat001: me <- blind 8O
so simple...... 8)

Posted: Wed Sep 04, 2002 3:55 am
by pat001
davidmcc - if you want to use <? short tags, look in your php.ini and set short_open_tag = On
volka - that's just what I thought when it clicked :idea:

But

Posted: Wed Sep 04, 2002 7:33 am
by davidmcc
I still can't logon, but I think debug displays will guide me through, now.