Page 1 of 1

Newbie question: require_once() is not working

Posted: Tue May 01, 2007 12:46 pm
by victorsk
Hello,

I have a very strange problem. The require_once() function doesn't seem to be working, it works fine on my other servers, but not on another.

I've deployed all the packages like SOAP/pear, restarted Apache, but I just get a blank screen when trying to use require_once(). I even researched for error-handling but I still get a blank page, with no error messages at all, nothing, here's my code, hope somebody could help me with this one:

Code: Select all

<?php
/*
       this file is for getting data using SOAP requests
*/
try
{

require_once('SOAP/Client.php');// or die ("problems");
}

catch Exception ($e)
{
        echo $e->getMessage();
        //also tried $e->getMessage();
}
everything is just blank. When I try to get the actual printout of SOAP response, the page gets blank too. It also gets blank when I try to directly access Client.php file, but I get an error on another server (as it should) where require_once() is working.

Please help,
Thank you,
Victor.

Posted: Tue May 01, 2007 12:51 pm
by Begby
require_once doesn't throw an exception, so you need to remove the try/catch block as it won't fire.

Also, you should turn on all errors and warnings. I think this is probably giving you a fatal error, but since error reporting is off that is your problem. I don't remember the syntax you need to turn on the errors in code, but someone else here should be able to help with that, or you can google for "php error reporting".

Posted: Tue May 01, 2007 12:51 pm
by feyd
Your catch statement would generate a parse error, I believe. I can only assume you've removed a large amount of code for the example. Something tells me that code is important.

Posted: Tue May 01, 2007 1:31 pm
by RobertGonzalez
Try/Catch would look like this:

Code: Select all

<?php
try {
  // Something that could throw an exception
} catch (Exception $e) {
  echo $e->getMessage();
}
?>
However, require_once results in a fatal error if the file to include is not found, so you really should not try to use it in a try/catch block. Just call it.

Code: Select all

<?php
require_once 'SOAP/Client.php';
?>