php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20607 function included from parent script gets lost
Submitted: 2002-11-24 03:22 UTC Modified: 2003-02-04 16:48 UTC
From: nick at itomic dot com Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 4.2.3 OS: red hat 7.2
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: nick at itomic dot com
New email:
PHP Version: OS:

 

 [2002-11-24 03:22 UTC] nick at itomic dot com
I have a cms site, and _two_ functions in particular are getting lost somewhere within the execution of the script.

basically the script index.php calls:
index.php -> header.inc -> it_functions/it_db.php
           -> news/index.inc -> now.inc

when the script now.inc runs, it cant find two functions defined in it_db.php: it_GetNextID & it_GetFieldNames. the exact error is

Fatal error: Call to undefined function: it_getnextid() in /home/barnyard/public_html/cms/now.inc on line 113

I thought it may be memory_limit, which was 8M & i set it to 16M, but no joy.

It seems only these two functions get lost. Ill try to reproduce the problem with simple code a bit later when I get out of the office.

When we tried to include it_db.php from now.inc directly (immediately preceding the call to it_GetNextID) the _first_ function in it_db.php (connect_db) causes an error : 
Fatal error: Cannot redeclare connect_db() (previously declared in /usr/local/lib/php/it_functions/it_db.php:5) in /usr/local/lib/php/it_functions/it_db.php on line 5

The problem was solved by adding the two functions to the head of the file now.inc. 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-11-24 03:27 UTC] nick at itomic dot com
I will try & boil down the code & provide an example within the next day, & provide a sample href
 [2002-11-24 05:46 UTC] nick at itomic dot com
ok, boiled it down to pretty simple code. The problem seemed to stem from the filename and position of it_db.php, which is in a default included directory .home/lib/it_functions/. In the following example, if it_db.php was included in the same directory, all was ok. if /home/lib/it_db.php was renamed to /home/lib/it_database.php (or any other name), the code works fine

System:
red hat 7.2
php 4.2.3
kernel 2.4.18pre3
apache: 1.3.27
php is an apache module

file structure:

/home/lib/it_functions/it_db.php (in central code repos):

<?php

// Get next available unique ID
function it_GetNextID($table,$PrimaryKey) {
echo "works OK <br />";
}

// it_GetFieldNames - Get all field/column names of selected table and load into an array
function it_GetFieldNames($table) {
echo "works ok too <br />"
}

?>

blackisha.com/cms_phpdebug/index.php:
<?

include_once "it_functions/it_db.php";

$a = it_getnextid("table", "trjh");
?>
 [2002-11-24 05:51 UTC] nick at itomic dot com
to see the above on my live server, goto
http://www.blackisha.com/cms_phpbug_central/index.php

to see the result if it_db.php is included within the same directory, goto 
http://www.blackisha.com/cms_phpbug/index.php
 [2002-11-24 05:53 UTC] nick at itomic dot com
the only difference is in index.php:

<?

include_once "it_db.php";

$a = it_getnextid("table", "trjh");
?>
 [2002-11-24 12:36 UTC] iliaa@php.net
Looks like the include is failing, but the error is not being shown, could you increase your error level to display E_WARNING or change include_once to require_once.
 [2002-11-24 19:27 UTC] nick at itomic dot com
yep, will do that, but im using other files in the same directory. also what is the function to get/set config options in php via the script?
 [2002-11-25 00:28 UTC] nick at itomic dot com
ok index.php now reads (on the live site):

<?
ini_set("error_reporting", "E_ALL");
//echo "Error Level : " . ini_get("error_reporting") . "<br />";

require_once "it_functions/it_db.php";

$a = it_getnextid("table", "trjh");
?>

I dont get any msg at all now, but i should get an echo from it_GetNextID ... ?
 [2002-11-25 00:32 UTC] nick at itomic dot com
it doesnt matter if I do 

ini_set("error_reporting", "E_WARNING");
or
ini_set("error_reporting", "E_ALL");

or include_once / require_once

the site comes up with nothing when I set error_reporting
 [2002-12-04 18:19 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip


 [2002-12-12 07:45 UTC] nick at itomic dot com
ok ill try a cvs snapshot, 

btw the problem doesnt happen on our win2K test server (for once! windows being nice??)

ill see if this also happens on our soon-to-be-live redhat dev-box, ill be able to do lots more on that box than on the live one
 [2002-12-21 05:22 UTC] moriyoshi@php.net
Are you running your scripts on php-cli? I suspect another it_db.php, which is slightly different from the one you intend to include, exists in the same directory as where scripts run. Because in php-cli, include() or require() always tries to first seek the files in the CWD regardress of include_path.

 [2002-12-21 05:36 UTC] moriyoshi@php.net
Sorry, not cli, I mean cgi.
 [2002-12-26 05:23 UTC] nick at itomic dot com
no Im pretty sure it's a apache module. 100% sure actually. changes to the php.ini require a 'kill -USR1 <httpd pid>' to propagate to the php interpreter. Ill check if there are any it_db.php's laying about though. Ill check this out soon... on the local dev box. & ill be able to chop & change lots more. sorry for not being too quick in trying the cvs etc. christmas & all..
 [2003-01-20 21:56 UTC] sniper@php.net
Does PHP 4.3.0 work any better? And btw. the correct 
way to set error_reporting is to use this line:

error_reporting(E_ALL);


 [2003-02-04 16:48 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Oct 06 17:01:27 2024 UTC