Question regarding Include statements

Hello, this is my first post, thanks in advance for any help you all can offer

I am working on my first website using php/mysql and have run into a problem early on.

First, I do have apache/php/mysql running and after several tests, they are working well.

I am working on a simple page where users can input some information that will be stored in a database.

The page is created and was/is working when it is all self contained within the index.php document, however, when I remove the following code from the index document and place it into another document it fails to work.

<?php $hostname = "localhost"; $db_user = "*****"; $db_password = "******"; $database = "bookBase"; $db_table = "users"; $db = mysql_connect($hostname, $db_user, $db_password); mysql_select_db($database,$db); ?>

MY INCLUDE STATEMENTS IN THE index.php DOCUMENT LOOKS LIKE THIS:

<?php include ('home/blaise/public_html/secure/config.php'); include ('home/blaise/public_html/secure/functions.php'); ?>

Ok, so what am I doing wrong?

Like I said, these scripts are working when they are all on the same page and I have also tested simple include scripts using just text and can confirm that the includes are working to at least that degree.

BTW The error I get when I submit data with the includes is:
ERROR: Access denied for user ‘www-data’@‘localhost’ (using password: NO)

Also, I think you’ll catch this but just wanted to make sure I let you all know the 2 includes are separated into 2 docs:

THIS IS IN config.php:

<?php $hostname = "localhost"; $db_user = "*****"; $db_password = "******"; $database = "bookBase"; $db_table = "users"; ?>

and THIS IS IN functions.php:

<?php $db = mysql_connect($hostname, $db_user, $db_password); mysql_select_db($database,$db); ?>

The problem isn’t the includes.
Insure you have your config.php information correct.
Because its not granting you access. Thats the issue.

Yeah, the info is correct. It grants me access if the statements are all on the index.php page. I’ve copied and pasted the working config settings straight over to the other file and then it doesn’t work. Anything else I should look at?

I just tried doing an include on a simple echo statement and that isn’t showing up now either. I was sure it was working before. But isn’t now. SO, is there something that might be keeping includes from working?

OOOOOHHHH, I think I just got it to work. The / is missing in front of home and also changed single quotes to double quotes.

Sponsor our Newsletter | Privacy Policy | Terms of Service