Page 1 of 1

PHP Stops With No Error Message

Posted: Thu Jul 01, 2010 11:22 am
by jcobban
I am baffled as to how to debug a case where PHP simply stops interpreting a page with no error message.

In the main page I have:

Code: Select all

...
    require_once "/home/jcobban/includes/legacyAddress.inc";
print "<p>require_once '/home/jcobban/includes/legacyHeader.inc'";
    require_once "/home/jcobban/includes/legacyHeader.inc";
print "<p>about to open a database connection</p>\n";
...
The first print statement is executed. The second is not.

The referenced file contains:

Code: Select all

<?php
/**
 *  legacyHeader.inc
 *
 *  Definition of a class representing a header entry in a genealogical
 *  database as implemented by Legacy 7 Family Tree.  This class provides
 *  access to the information in the table tblHR.
 *
 *  Copyright &copy; 2010 James A. Cobban
 *
 **/

/**
 *  legacyHeader
 *
 *  Definition of a class implementing behavior for header entry records
 *  within a genealogy database as implemented by Legacy 7 Family Tree.
 *
 **/

class legacyHeader 
{
    /**
     *	legacyHeader::table
     *
     *	Associative array containing all key/value pairs in header.
     **/
    private	table;

    /**
     *	legacyHeader::__construct
     *
     *  Given the identifier extract information about a header entry.
     *
     *  Input:
     *	$conn	connection resource to database
     *
     *  Returns object containing header record.
     **/
    function __construct($conn)
    {
	// construct the query of the header table
	$query	= "SELECT Item, Setting FROM tblHR;";
	
	// query the database
	print "<p>$query</p>";
	$this->connection->setFetchMode(MDB2_FETCHMODE_ASSOC);
	$result	= doQuery($this->connection,
			  $query);

	$this->table	= array();	
	while(($dbrow	= $result->fetchRow()) != null)
	{		// copy all entries into table
	    $this->table[$dbrow['item']]	= $dbrow['setting'];
	}		// copy all entries into table
    }		// legacyHeader::__construct

    /**
     *	legacyHeader::getSetting
     *
     *	Get the setting value corresponding to an item name.
     **/
    function getSetting($item)
    {
	// action depends upon type of first parameter
	if (is_string($item))
	{		// numeric identifier of record
	    return $this->table[$item];
	}		// item name
	else
	{
	    print "<p class='message'>legacyHeader::getSetting: called with " .
		 gettype($item) . "<\p>\n";
	    return '';
	}

    }		// legacyHeader::getItem

    /**
     *	legacyHeader::getKeys
     *
     *	Get an array containing all of the keys in the header.
     **/
    function getKeys()
    {
	$retval	= array();
	$i	= 0;
	foreach($this->table as $key => $value)
	{
	    $retval[$i]	= $key;
	    $i++;
	}		// loop through all elements in table
	    
    }		// legacyHeader::getItem

}		// class legacyHeader 
?>
And just to reassure you that the file in question is where I told PHP to look for it:

Code: Select all

$ ls -l /home/jcobban/includes/*.inc
-rw-rw-rw- 1 jcobban jcobban   529 2010-05-01 22:34 /home/jcobban/includes/db.inc
-rw-rw-rw- 1 jcobban jcobban   523 2010-04-12 15:36 /home/jcobban/includes/dbIsp.inc
-rw-r--r-- 1 jcobban jcobban 13515 2010-06-29 21:18 /home/jcobban/includes/formUtil.inc
-rw-r--r-- 1 jcobban jcobban  4535 2010-05-24 00:48 /home/jcobban/includes/legacyAddress.inc
-rw-r--r-- 1 jcobban jcobban  7255 2010-05-28 00:21 /home/jcobban/includes/legacyCitation.inc
-rw-r--r-- 1 jcobban jcobban  4404 2010-06-03 17:25 /home/jcobban/includes/legacyFamily.inc
-rw-r--r-- 1 jcobban jcobban  2232 2010-07-01 12:03 /home/jcobban/includes/legacyHeader.inc
-rw-r--r-- 1 jcobban jcobban 12117 2010-06-11 05:13 /home/jcobban/includes/legacy.inc
-rw-r--r-- 1 jcobban jcobban 17848 2010-06-20 13:44 /home/jcobban/includes/legacyIndiv.inc
-rw-r--r-- 1 jcobban jcobban  3990 2010-06-11 04:23 /home/jcobban/includes/legacyLocation.inc
-rw-r--r-- 1 jcobban jcobban  1725 2010-05-22 10:52 /home/jcobban/includes/legacyRecord.inc
-rw-r--r-- 1 jcobban jcobban  3889 2010-05-24 00:51 /home/jcobban/includes/legacySource.inc
PHP seems to simply stop dead when it comes to that require_once statement.

How do I figure out what the problem is?

Re: PHP Stops With No Error Message

Posted: Thu Jul 01, 2010 11:29 am
by AbraCadaver
You need to have error reporting on so you can see parse errors:

Code: Select all

private     table;

Re: PHP Stops With No Error Message

Posted: Thu Jul 01, 2010 11:50 am
by jcobban
AbraCadaver wrote:You need to have error reporting on so you can see parse errors:

Code: Select all

private     table;
Thank you. I admit that I find it confusing that when I declare a member variable of a class I must put a $ at the front of the name, even though when the variable is referenced in the code the $ is omitted!

I am trying to turn on error reporting. I have updated php.ini, but I cannot for the life of me figure out how to restart the Apache server. I go to the Apache 2.2 documentation which instructs me to use the apachectl command. There is no apachectl command! There is an apache2ctl command but when I try that I get:

[text]$ sudo apache2ctl restart
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[/text]
and nothing happens.

I am running Ubuntu Lucid.

Re: PHP Stops With No Error Message

Posted: Thu Jul 01, 2010 12:01 pm
by jcobban
I have succeeded in restarting Apache by adding an explicit ServerName in httpd.conf. However the php.ini setting has not taken effect. The php.ini in my server web directory contains:
[text]include_path = ".:/usr/lib/php:/usr/local/lib/php:/home/jcobban/php"
extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613"
magic_quotes_gpc = "0"
extension="suhosin.so"
suhosin.post.max_vars = 2000
suhosin.request.max_vars = 5000
display_errors = On[/text]
But when I invoke phpinfo.php it says that display_errors is off, and moreover none of the values from my php.ini are effective! The Suhosin section of the list does not even appear in the output!

I have also tried display_errors = "On" and display_errors = "1".

Re: PHP Stops With No Error Message

Posted: Thu Jul 01, 2010 12:26 pm
by AbraCadaver
That's not a fatal error, so it probably did restart. Check with 'ps -ef|grep apache'

For development you can have error_reporting = E_ALL as well.