Alright, so this is something really basic, and I know that when someone tells me the answer I'm going to feel really silly, but I can't for the life of me figure out why the following code isn't working:
index.php:
<?php include('config.php'); //this works fine. variables in this file are reached correctly - $_MYSQL is defined there ?>
<?php include($_MYSQL); ?>
<?php echo ($fruit);?>
db_config.php (which is what $_MYSQL links to, this works no problem):
<?php
$fruit = "apple";
echo($fruit);
?>
for completeness config.php looks like:
<?php
$_MYSQL = 'http://'.$_SERVER['HTTP_HOST'].'/public_html/db_config.php';
$BASE_URL = 'http://'.$_SERVER['HTTP_HOST'].'/public_html/Opto10/';
?>
So as the names imply the code is meant to contact this db_config.php that then connects to the database, but for some reason the variables in the db_config file don't seem to carry across to index.php. The weird thing is that include('config.php'); works perfectly fine, but in the code I've shown above in the index.php "echo($fruit);" doesn't print out anything. The same line in db_config.php does though (so I guess that it does mean it's included). Somehow the variables aren't passed along. Just so you know, in case this makes a difference, the db_config.php file is located in the parent of the current directory.
I'm thoroughly puzzled, any help is extremely welcome. Thanks in advance,
Simon
What you have abovev is literally all my php code.