Bluehost.com Web Hosting $6.95

require_once dying silently

This is a discussion on require_once dying silently within the PHP General forums, part of the PHP Programming Forums category; Hi, everyone. This one's been driving me bonkers for an hour now. Anyone have any idea why require_once would ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-09-2008
Richard S. Crawford
 
Posts: n/a
Default require_once dying silently

Hi, everyone.

This one's been driving me bonkers for an hour now. Anyone have any idea
why require_once would be dying silently in the script below?

------------------------------------

$CFG->dirroot = "/home/rcrawford/public_html/tanktrunk/tanktrunk";
$CFG->dataroot = $CFG->dirroot.'/moodledata';

require_once("$CFG->dirroot/lib/setup.php");
------------------------------------

I've confirmed that the file setup.php exists and is readable. I've got
error_reporting in php.ini set to E_ALL. I'm running Apache 2 and PHP5 on
Kubuntu 7.10. Nothing shows up in my apache error log, and PHP itself
produces absolutely no output, even though it will produce output galore
when I put in a deliberate syntax error.

I've also tried:

------------------------------------
require_once($CFG->dirroot."/lib/setup.php");
------------------------------------

but this didn't help.

Any assistance at all would be greatly appreciated.

--
Richard S. Crawford (rscrawford@mossroot.com)
http://www.mossroot.com
Publisher and Editor in Chief, Daikaijuzine (http://www.daikaijuzine.com)

Reply With Quote
  #2 (permalink)  
Old 04-09-2008
Chris
 
Posts: n/a
Default Re: [PHP] require_once dying silently

Richard S. Crawford wrote:
> Hi, everyone.
>
> This one's been driving me bonkers for an hour now. Anyone have any idea
> why require_once would be dying silently in the script below?
>
> ------------------------------------
>
> $CFG->dirroot = "/home/rcrawford/public_html/tanktrunk/tanktrunk";
> $CFG->dataroot = $CFG->dirroot.'/moodledata';
>
> require_once("$CFG->dirroot/lib/setup.php");
> ------------------------------------
>
> I've confirmed that the file setup.php exists and is readable. I've got
> error_reporting in php.ini set to E_ALL. I'm running Apache 2 and PHP5 on
> Kubuntu 7.10. Nothing shows up in my apache error log, and PHP itself
> produces absolutely no output, even though it will produce output galore
> when I put in a deliberate syntax error.


Syntax errors in which file? The calling one (where you have the
require_once) or the lib/setup.php file?

Maybe something in your code is disabling your error reporting, I'd put
both:

error_reporting(E_ALL);
ini_set('display_errors', true);

in before the require_once and see what happens.

--
Postgresql & php tutorials
http://www.designmagick.com/
Reply With Quote
  #3 (permalink)  
Old 04-09-2008
Greg Bowser
 
Posts: n/a
Default Re: [PHP] require_once dying silently

<?php echo 'begin brainstorm.'; ?>

Is it possible that something is "going wrong" between the definition
of $CFG->foo and when you require that could cause $CFG->dirroot to be
null? Then it would point to /lib/setup.php, which definitely
shouldn't exist and should thus throw an error, but maybe it's worth
looking into.

<?php require_once('Have you tried including a file that definitely
does not exist?'); ?> That would rule out any error reporting problems
anyway.

Have you tried something to the effect of <?php echo __FILE__ . '
included'; ?> on the first line of setup.php? Adding <?php
print_r(get_included_files()); ?> after the require_once() might also
help.

> I've confirmed that the file setup.php exists and is readable.

I apologize if this seems obvious, but for the sake of
brainstorming... it's readable by the user running apache, right? And
even if it weren't, that should have thrown an error *shrugs*

That's all I can think of. I hope it is of some use to you.

<?php echo 'end brainstorm.'; ?>

<?php signature('GREG'); ?>
Reply With Quote
  #4 (permalink)  
Old 04-09-2008
Casey
 
Posts: n/a
Default Re: [PHP] require_once dying silently

On Tue, Apr 8, 2008 at 8:27 PM, Greg Bowser <topnotcher@gmail.com> wrote:
> <?php echo 'begin brainstorm.'; ?>
>
> Is it possible that something is "going wrong" between the definition
> of $CFG->foo and when you require that could cause $CFG->dirroot to be
> null? Then it would point to /lib/setup.php, which definitely
> shouldn't exist and should thus throw an error, but maybe it's worth
> looking into.
>
> <?php require_once('Have you tried including a file that definitely
> does not exist?'); ?> That would rule out any error reporting problems
> anyway.
>
> Have you tried something to the effect of <?php echo __FILE__ . '
> included'; ?> on the first line of setup.php? Adding <?php
> print_r(get_included_files()); ?> after the require_once() might also
> help.
>
>
> > I've confirmed that the file setup.php exists and is readable.

> I apologize if this seems obvious, but for the sake of
> brainstorming... it's readable by the user running apache, right? And
> even if it weren't, that should have thrown an error *shrugs*
>
> That's all I can think of. I hope it is of some use to you.
>
> <?php echo 'end brainstorm.'; ?>
>
> <?php signature('GREG'); ?>
>
>


You should try:
<?php
require_once("/home/rcrawford/public_html/tanktrunk/tanktrunk/lib/setup.php");
?>

--
-Casey
Reply With Quote
  #5 (permalink)  
Old 04-09-2008
Zoltán Németh
 
Posts: n/a
Default Re: [PHP] require_once dying silently

Richard S. Crawford Ã*rta:
> Hi, everyone.
>
> This one's been driving me bonkers for an hour now. Anyone have any idea
> why require_once would be dying silently in the script below?
>
> ------------------------------------
>
> $CFG->dirroot = "/home/rcrawford/public_html/tanktrunk/tanktrunk";
> $CFG->dataroot = $CFG->dirroot.'/moodledata';
>
> require_once("$CFG->dirroot/lib/setup.php");


the above won't work, as the parser will try to interpret $CFG and put
it in the string first, then go ahead.
try this:
require_once($CFG->dirroot."/lib/setup.php");
or this:
require_once("{$CFG->dirroot}/lib/setup.php");

greets,
Zoltán Németh

> ------------------------------------
>
> I've confirmed that the file setup.php exists and is readable. I've got
> error_reporting in php.ini set to E_ALL. I'm running Apache 2 and PHP5 on
> Kubuntu 7.10. Nothing shows up in my apache error log, and PHP itself
> produces absolutely no output, even though it will produce output galore
> when I put in a deliberate syntax error.
>
> I've also tried:
>
> ------------------------------------
> require_once($CFG->dirroot."/lib/setup.php");
> ------------------------------------
>
> but this didn't help.
>
> Any assistance at all would be greatly appreciated.
>


Reply With Quote
  #6 (permalink)  
Old 04-09-2008
Aschwin Wesselius
 
Posts: n/a
Default Re: [PHP] require_once dying silently

Richard S. Crawford wrote:
> Hi, everyone.
>
> This one's been driving me bonkers for an hour now. Anyone have any idea
> why require_once would be dying silently in the script below?
>
> ------------------------------------
>
> $CFG->dirroot = "/home/rcrawford/public_html/tanktrunk/tanktrunk";
> $CFG->dataroot = $CFG->dirroot.'/moodledata';
>
> require_once("$CFG->dirroot/lib/setup.php");
>


Hi,

It reads as if $CFG is an object and ->dirroot is not a public property
of that object. So, I don't know what $CFG is, but I think the problem
lays there.

Also, OOP is nice and all (not to start a thread about OOP again), but
putting your config into an object seems a bit overdo to me.

--

Aschwin Wesselius

/'What you would like to be done to you, do that to the other....'/

Reply With Quote
  #7 (permalink)  
Old 04-09-2008
Zoltán Németh
 
Posts: n/a
Default Re: [PHP] require_once dying silently

Aschwin Wesselius Ã*rta:
> Richard S. Crawford wrote:
>> Hi, everyone.
>>
>> This one's been driving me bonkers for an hour now. Anyone have any idea
>> why require_once would be dying silently in the script below?
>>
>> ------------------------------------
>>
>> $CFG->dirroot = "/home/rcrawford/public_html/tanktrunk/tanktrunk";
>> $CFG->dataroot = $CFG->dirroot.'/moodledata';
>>
>> require_once("$CFG->dirroot/lib/setup.php");
>>

>
> Hi,
>
> It reads as if $CFG is an object and ->dirroot is not a public property
> of that object. So, I don't know what $CFG is, but I think the problem
> lays there.


if that property is not public but protected or private it would throw a
fatal error.

>
> Also, OOP is nice and all (not to start a thread about OOP again), but
> putting your config into an object seems a bit overdo to me.
>


I think you know I don't agree with that, but I too don't want to start
this over ;)

greets,
Zoltán Németh
Reply With Quote
  #8 (permalink)  
Old 04-09-2008
Greg Bowser
 
Posts: n/a
Default Re: [PHP] require_once dying silently

>the above won't work, as the parser will try to interpret $CFG and
put it in the string first,

In that case, $CFG is either null, or it is indeed an object. If it is
a standard object, which I it appears to be, then a fatal error will
be thrown because there is no __tostring() function. If it's null,
then require_once is referencing a directory beginning with '->',
again, there *should* be an error. Anyway..

I've seen $obj->property used many times in double quotes, and never
had a problem with that working. Personally though, I always use the
curly braces though because it highlights better in VIM :p

>Also, OOP is nice and all (not to start a thread about OOP again),

but putting your config into an object seems a bit overdo to me.

Me too!! (not to continue the unstarted OOP discussion) It's a
practice I've seen used more than once. I think people find that
syntax attractive.
Reply With Quote
  #9 (permalink)  
Old 04-09-2008
Zoltán Németh
 
Posts: n/a
Default Re: [PHP] require_once dying silently

Greg Bowser Ã*rta:
>> the above won't work, as the parser will try to interpret $CFG and

> put it in the string first,
>
> In that case, $CFG is either null, or it is indeed an object. If it is
> a standard object, which I it appears to be, then a fatal error will
> be thrown because there is no __tostring() function. If it's null,
> then require_once is referencing a directory beginning with '->',
> again, there *should* be an error. Anyway..
>
> I've seen $obj->property used many times in double quotes, and never
> had a problem with that working. Personally though, I always use the
> curly braces though because it highlights better in VIM :p


I stand corrected, I just tried putting an object property into double
quotes and it works

greets,
Zoltán Németh

>
>> Also, OOP is nice and all (not to start a thread about OOP again),

> but putting your config into an object seems a bit overdo to me.
>
> Me too!! (not to continue the unstarted OOP discussion) It's a
> practice I've seen used more than once. I think people find that
> syntax attractive.
>


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 05:24 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0