Tech Support Guy banner

require($_SERVER['DOCUMENT_ROOT'] help!

3470 Views 10 Replies 2 Participants Last post by  brendandonhu
Hey, I watched the 3D Buzz php&mysql series like 10 times. Love the tutorials.

I got apache php and mysql very easily set up but I am having a problem with require.

My php works when I do arithmetics, or date, or printing stuff but not with require. This code is an example from tutorials for practicing php.

$connection=mysql_connect($db_host, $db_user, $db_password) or die("error");

echo $db_host;

This is what I put, and theoretically it should print for me $db_host defined in config/config.php. But it doesn't. It doesn't show anything. Infact if I include this code with HTML documents, the HTML won't show either.

Has the syntax for document_root changed for later versions of PHP?

What is the problem? I even shut off my firewall etc. No good.

The only thing I can think of is my root is in C: so is my PHP folder, my apache and MySQL are in program files in their default places. maybe mysql_connect (); doesnt know where to look for the monitor? help please!
Not open for further replies.
1 - 5 of 11 Posts
require() should give you an error if it's not working. You could
echo $_SERVER['DOCUMENT_ROOT'] . '/config/config.php'
to see what folder it's looking it.
Is there no error printed?
You may need to add
to the beginning of your script to show the error messages.

You also might not have compiled PHP with MySQL support - it's no longer built-in by default. You can run phpinfo() and look for a "MySQL" section to find out.
1 - 5 of 11 Posts
Not open for further replies.