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());
?> 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.