Spinal
MB Enthusiast
- Joined
- Sep 14, 2004
- Messages
- 4,806
- Location
- between Uxbridge and the Alps
- Car
- x254, G350, Duster, S320, Mach1, 900ss and a few more
I'm working on my site, and I've decided to redesign the backend so I can upload images remotely...
I've also fiddled with the format, so in essence I want to be able to edit some basic components without using dreamweaver...
Anyhow, I've made a file "database.php" with my database details, so that throughout the site I can just call that...
This way, anywhere I need to run a query, I should be able to do this:
right?
Now comes the part that I don't understand... See that echo statement (where I've commented out the if($DEBUG)?) - that shows me that all those variables are BLANK.... NULL... and I can't figure out why! Surely, as I've defined them as global variables three lines above they should still be instantiated?
M.
I've also fiddled with the format, so in essence I want to be able to edit some basic components without using dreamweaver...
Anyhow, I've made a file "database.php" with my database details, so that throughout the site I can just call that...
PHP:
<?php
$DEBUG = true;
$db_name = "dbname";
$db_server = "localhost";
$db_user = "dbuser";
$db_pass = "dbpassword";
//$db_table = "photos";
//$another_table ="some_other_table";
//...etc (not yet implemented for more than one table)
function runQuery($q) {
//if ($DEBUG){
echo "($db_server, $db_user, $db_pass)";
//}
$link = mysql_connect($db_server, $db_user, $db_pass);
@mysql_select_db($db_name) or die( "Unable to select database");
mysql_query($q);
mysql_close();
}
?>
This way, anywhere I need to run a query, I should be able to do this:
PHP:
require 'database.php';
$query = "DROP TABLE photos";
runQuery($query);
right?
Now comes the part that I don't understand... See that echo statement (where I've commented out the if($DEBUG)?) - that shows me that all those variables are BLANK.... NULL... and I can't figure out why! Surely, as I've defined them as global variables three lines above they should still be instantiated?
M.