php include/require doesn't work

Hi experts.  I'm using php 5.2.6 on my test xampp/apache server.  

All of a sudden my include ("") has stopped working. When I copy the content of the included file into the parent program it is fine.  Changing to require("") has no effect, neither does changing from to xxxx.php.

Thoroughly confused here, any help much appreciated.

Colin BrazierAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Beverley PortlockCommented:
First thing to do is turn error checking on and look for any error messages. Add the following line just after the first <?php tag like so


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

Post back any error messages.
Colin BrazierAuthor Commented:
Thanks for responding.

Without the ini_set change, the error is:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\index1.php  on line 22
The connection to the mySQL server failed.

Because the included file has the connect info.

With the ini_set:

Notice: Undefined variable: host in C:\xampp\htdocs\index1.php  on line 23

Notice: Undefined variable: user in C:\xampp\htdocs\index1.php on line 23

Notice: Undefined variable: password in C:\xampp\htdocs\index1.php on line 23

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\index1.php on line 23
The connection to the mySQL server failed.

Beverley PortlockCommented:
OK, since you are on windows, permissions should not be a major problem (unlike Linux) but you might want to check them by right clicking the appropriate folders and looking at the properties.

I suggest that we check the path next and make sure that the .inc file is somewhere that the include/require can actually find it. Execute


and do a scan for include_path and check that the folder where your include files are kept are in the include path. Also remember that it is best to use '/' as directory separators on Windows as PHP translates then to '\' for you and it avoids the  "escaping" issues that you get with using '\'
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

Colin BrazierAuthor Commented:
I think you are on the right lines.  I have corrected the path in the .ini file but it's having no effect, so presumably that means restarting apache.  Do I need to reboot my PC to do that?  (sorry, getting into basics here!).

Beverley PortlockCommented:
YOu should be able to restart Apache from the XAMPP control panel, but I cannot remember how to do it. Restarting the PC is probably simplest.

Also do a scan for .ini files - there are often TWO of them. One for Apache and one for CLI usage using PHP in a non-webserver environment). Use the Windows search for php.ini and just see how many you have and make sure you edit the correct one.
Beverley PortlockCommented:
Another thing to try (should have mentioned it earlier...) when doing includes, rather than

include '';


include './' ;

to enforce the relative path from the current directory. This prevents PHP from deciding how it will interpret things.
Colin BrazierAuthor Commented:
Still the same.  From phpinfo:

Configuration File (php.ini) Path       C:\WINDOWS
Loaded Configuration File       C:\xampp\apache\bin\php.ini

Are these contradicting each other??  The php.ini I have been amending is C:\xampp\apache\bin\php.ini

There is no php.ini in c:|WINDOWS

php.ini include path:        .;C:/xampp/htdocs/
Beverley PortlockCommented:
This is probably the cause. Did you use Window's "Search" to search the entire machine for files called php.ini?

Look at this

The path that says " .;C:/xampp/htdocs/" is probably the correct path because it includes "." which is the current directory. If your PHP installation is using "C:\WINDOWS" then it explain why your include files are not being found.

Scan the entire machine for php.ini files, don't just look in one or two places. It'll take five minutes and you'll know what you are up against.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Colin BrazierAuthor Commented:
Many thanks!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.