create .ini file for mysql database connection.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
prasadb2005
Forum Newbie
Posts: 7
Joined: Tue May 19, 2009 1:18 am

create .ini file for mysql database connection.

Post by prasadb2005 »

Hi,
I want to create a .ini file to make a connection with mysql database.

It is said that that file contains all the details of variables like server name, username, password,database name and connection.

I am using WAMP server for mysql GUI and netbeans 6.5.1 editor for php.

I din't create .ini file before this.
Please help me to create the .ini file for making database connection with mysql.
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: create .ini file for mysql database connection.

Post by yacahuma »

you want to create a file that contains your connection parameters for your code?? First dont call it .ini always use .php

Code: Select all

 
$host     = "localhost";
$database = "database";
$username = "username";
$password = "password";
 
require_once "adodb/adodb-exceptions.inc.php";
require_once 'adodb/adodb.inc.php';
try
{
  $GLOBAL_CN = NewADOConnection('mysql');
  $GLOBAL_CN->SetFetchMode(ADODB_FETCH_ASSOC);
  $GLOBAL_CN->Connect($host, $username, $password,$database);
  $GLOBAL_CN->debug = false;
 // $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
} catch (exception $e) {
        var_dump($e);
        adodb_backtrace($e->gettrace());
//    $msg = "Unable to conect to Database";
}
 
Post Reply