Jump to content

[SOLVED] Refrencing one db to select another


jaxdevil

Recommended Posts

Anyone see the error here? I can't, but the sql error statement says "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select' at line 1" and i do not have select at line 1, its at line 10. What I am trying to do is this, this is my config.inc.php file, i want to dynamically change the database and username using php, so I made a seperate database called auction_select and made a single table called 'select' with one field 'auctdb', all the databases would be listed in the 'select' table and when a seperate one is selected, the config.inc.php would update the auction database and username (they are both the same for each database) to match the new db we want to use. So I am trying to make the term $auctdb display what is in the field for auctdb, thereby changing the database that the config.inc.php selects. Any ideas?

 

<?php
$db_host = "localhost";
$db_user = "auction_select";
$db_pwd = "xxxxxx";
$db_name = "auction_select";
mysql_connect($db_host, $db_user, $db_pwd);
mysql_select_db($db_name) or die(mysql_error()); 
?>
<?php
$sql = "SELECT * FROM select";
$query = mysql_query($sql) or die(mysql_error()); 
while ($row = mysql_fetch_array($query)) {
$auctdb = $row[auctdb];
echo $auctdb;
echo "test";
}
?>
<?php
$db_host = "localhost";
$db_user = "$auctdb";
$db_pwd = "xxxxxx";
$db_name = "$auctdb";
mysql_connect($db_host, $db_user, $db_pwd);
mysql_select_db($db_name)  or die(mysql_error());
?> 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.