obay Posted July 19, 2007 Share Posted July 19, 2007 im not sure this is the right place to ask, if it's not, please refer me to another forum.. anyway, here goes.. i have a php application, with a database having a table "settings" with two columns, "field" and "value": settings.php: //code to extract the settings from the database into $settings $settings = array (); $settings_query = mysql_query("SELECT * FROM settings"); //settings include the database hostname, uname, pw, etc while ($setting = mysql_fetch_array($settings_query)) { $settings[$setting[field]] = $setting[value]; } what im trying to do is save application settings (including the database hostname, username, password, etc) into the database, through the table "settings". so now you know my problem is that i can't connect to the database in order to get the database connect info because in the first place i don't have the database connect info to connect to the database.. ( stupid problem right? ) currently the settings are saved in a .php file(as php variables) but the reason i want to save them in a database is because i have a editSettings.html file - which has an html form for easy editing of the settings (doesn't have to be done by editing php code manually), and saves the changes into the database. this is not actually a question, but i'm asking for any suggestions. any help appreciated... Link to comment https://forums.phpfreaks.com/topic/60746-php-connect-to-mysql-database-complicated-problem-help/ Share on other sites More sharing options...
ToonMariner Posted July 19, 2007 Share Posted July 19, 2007 while ($setting = mysql_fetch_array($settings_query)) { $settings[$setting[field]] = $setting[value]; } change that line to... while ($setting = mysql_fetch_array($settings_query)) { foreach($setting as $key => $val) { $settings[$$key][] = $val; } } seems pointless saving database connection details in a database where you need those details to access it anyway.... Link to comment https://forums.phpfreaks.com/topic/60746-php-connect-to-mysql-database-complicated-problem-help/#findComment-302182 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.