Fatal error: require_once() [function.require]: Failed opening required 'db.php'

I have a homebrew CMS I’m working on, I’ve got it functioning fine on my local server(Apache on OS X), but it doesn’t work on 000.

I couldn’t find a quick fix, so I decided to create a minimal test case to see if I still got the error on db.php. I did. Here is the test case. The ‘echo “Hello World!”’ is to verify that this test script is in fact executing.

<?php 
echo "Hello World!";
require_once('db.php'); ?>

This file is set to permissions 755.

Here is what it gives back to me when I load that page:

Hello World!
PHP Error Message

Warning: require_once(db.php) [function.require-once]: failed to open stream: No such file or directory in /home/a2834921/public_html/test.php on line 3

Free Web Hosting

PHP Error Message

Fatal error: require_once() [function.require]: Failed opening required 'db.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/a2834921/public_html/test.php on line 3

Same errors as I got on my actual code, so it appears that I nailed the simplified test case.

db.php is the PEAR DB module for PHP, which I use to access MySQL. Is there something special about using this module here? Or is an entirely different module in use? If so, could someone kindly direct me to a howto on that module so I can change my database access code? I’ve tried a forum search, but I could only find a few references on specific issues, not a ground up tutorial which I’d need. RTFM is a fine answer, I just need a little help finding the FM I think.

Hi gworr0ll,

You get that error because the server can not find the file db.php
Where you saved it? Should be in the same folder where you put the test.php file.

db.php is not part of my code, it’s a PEAR module that is normally installed alongside PHP itself. I don’t think I have sufficient access to install it, as that is normally done through shell commands.

Hi,

If you want to include the db.php file you must upload or you must can access this file.
If it is installed you do not need to call, simply use the functions and classes that are defined within this file.

To see if this module is installed in PHP configuration looks “Members Area” -> CPanel -> “View PHP Configuration”

Edit / Add
Have you tried your test.php file in your local server?

out of curiosity, whats so special about this db.php file, connecting to an sql db is fairly easy, you could do that your self…

(/me is new to this)


Live ■■■

Haven’t put test.php on my local server. The local server never gave me this error in the first place, so there was no need for a simplified test case.

kei- db.php basically makes it much easier to port from one type of database to another. In ideal situations, all that it would take to bring a db.php app from MySQL to Oracle(or whatever other SQL server) would be to change the connection string. All your database access calls would then automatically adjust to what Oracle wanted. Of course, the real world can be more complicated than this ideal, but it does make supporting different backends much easier.

Hi gworroll,

If you had tested your test.php file on your local server you would have found that the same mistake because the concept you are using to test is incorrect.

Have you checked if 000webhost supports the module db PEAR you want to use?