jaxdevil Posted December 12, 2007 Share Posted December 12, 2007 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()); ?> Quote Link to comment Share on other sites More sharing options...
effigy Posted December 12, 2007 Share Posted December 12, 2007 SELECT is a keyword; how about SELECT * FROM `select`? Quote Link to comment Share on other sites More sharing options...
jaxdevil Posted December 12, 2007 Author Share Posted December 12, 2007 Your a genius, I am a bit retarded today Thanks a billion man! SK Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.