Posted by Jerry Stuckle on 08/30/07 03:54
Morlaath@gmail.com wrote:
> On Aug 29, 10:45 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>> Morla...@gmail.com wrote:
>>> Ok .. I have some classes set up to do some database queries and what
>>> not. The database configuration is an XML file. Now I need to include
>>> this class in a few pages, in different directories. Here is an
>>> example of the class.
>>> class foo {
>>> private $xml;
>>> function foo() {
>>> $this->xml = simplexml_load_file('config/dbconfig.xml);
>>> }
>>> public function dbStuff() {
>>> //do some db stuff
>>> }
>>> etc......
>>> }
>>> I am using apache which has php set up as a module. This class (which
>>> resides 2 directories deep e.g htdocs/classes/foo) works fine in
>>> main.php which resides in htdocs. But if I include this class in
>>> another php file which is in a different directory .... say htdocs/
>>> forums I get this type of error:
>>> Warning: simplexml_load_file() [function.simplexml-load-file]: I/O
>>> warning : failed to load external entity "config/dbconfig.xml"
>>> I tried using set_include_path(), which I could not get to work right,
>>> and I also tried to set 'include_path' in php.ini which also did not
>>> work. PHP include seems to work very non-intuitive which is driving me
>>> nuts. They really need to implement this a little better. I really
>>> don't see why the simplexml_load_file works in htdocs/classes/foo and
>>> not htdocs/forums.
>> Some code would help...
>>
>> --
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> JDS Computer Training Corp.
>> jstuck...@attglobal.net
>> ==================
>
> Uh ...what do you call this?
> class foo {
> private $xml;
>
> function foo() {
> $this->xml = simplexml_load_file('config/dbconfig.xml);
> }
>
> public function dbStuff() {
> //do some db stuff
> }
>
> etc......
>
> }
>
You didn't say *ANYTHING* about how you include it - which is your
*REAL* problem.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|