Jump to content

Here is a simple Config file


2old2learn?

Recommended Posts

Hey; My little contribution here..a simple config.file for database connection...Config.php code:

<?php//////////////////////////////////////////////////////////////////////////////						   Configuration File						//////				 connects to database and other base files...		//////																	 /////////////////////////////////Database Information/////////////////////////$host="";$username="";$password="";$db_name=""; //////////////////////////////Database Access//////////////////////////////$con = mysql_connect("localhost","root","");if (!$con){   die('Could not connect: ' . mysql_error());   };	   mysql_select_db("", $con);	   ///////////////////////////////////////////////////////////////////////////	   ?>

hope this is some use for some of you...

Link to comment
Share on other sites

but the connection paramaters are still hardcoded, which makes it less useful. not trying to downplay the intent of the code snippet by any means.edit: there is quite a larger concept to creating config files and dynamic scripts that pull from actual config files, or from forms and whatnot. maybe if you created an environment config, and then this script pulled those values out and assigned them to $host, $username, $password, $db_name, and then those variables where used for mysql_connect and other such calls, you might be onto something.

Link to comment
Share on other sites

but the connection paramaters are still hardcoded, which makes it less useful. not trying to downplay the intent of the code snippet by any means.
Well, just thought this was more simpler than writing the db connection code on every file..by using include..config.php but I see your point...
Link to comment
Share on other sites

but the connection paramaters are still hardcoded, which makes it less useful. not trying to downplay the intent of the code snippet by any means.edit: there is quite a larger concept to creating config files and dynamic scripts that pull from actual config files, or from forms and whatnot. maybe if you created an environment config, and then this script pulled those values out and assigned them to $host, $username, $password, $db_name, and then those variables where used for mysql_connect and other such calls, you might be onto something.
That is my intension of making use of other files..in the config.php file...once I get a better handle on the php coding aspect of things...Looking to do something like this added to config.php file:
$site[homeurl]		=  ("example");$dir[base]			=  getcwd();$url[base]			="$site[homeurl]";$url[themes]		="$site[homeurl]/themes";$dir[func]			="$dir[base]/functions";$dir[themes]		="$dir[base]/themes";

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...