674Part IVConnections .Row (Michigan web site) retrieval .DisconnectionThe following subsections explain

674Part IVConnections .Row retrieval .DisconnectionThe following subsections explain each in turnData Source Names (DSNs) A Data Source Name (DSN) is simply a text string that describes where a database is and howto access it. A DSN is very much like a URL for a database. Because databases almost alwayshave user-level access control, DSNs specify usernames and passwords. Note that DSNs spec- ify the databaseto which your program is connecting, not the tablewithin the database. In order to form a DSN, you have to come up with a number of values: .The type of database you re connecting to (FrontBase, MySQL, Oracle, or whatever you fancy) .The hostname or IP address of the machine running the database server .The database name .The username you want the software to use .The corresponding passwordVery often, you ll need to access these values in order to create DSNs in several different butrelated PHP programs. For that reason, it often makes sense to assign the literal values tovariables in a special program that s imported elsewhere. Such a program might look like this(call it dbSpecs.php): The only odd bit there is the value for $phptype. Its value is a standard string that corre- sponds to a specific database (MySQL, in this example). The related sidebar shows all validoptions for the database identifier. Having defined your variables in a simple library, when you want to create a DSN, you canimport dbSpecs.phpand have access to its values. The advantage is that if the values indbSpecs.phpever change, you need to modify them in just one place. The import statementis simple: require_once( dbSpecs.php ); With that imported, you can use the values defined in dbSpecs.phpto create a DSN. Remember, though, that you need to register the variables if you create your DSN inside afunction (this is a standard characteristic of PHP variable scoping): global $phptype; global $hostspec; global $database; global $username; global $password;
If you are looking for cheap and quality webhost to host and run your website check Jboss Web Hosting services.

Leave a Reply