conf.php

Discussion in 'PHP' started by chinhelhas, Oct 18, 2009.

  1. #1
    can anyone please tell me about this

    <?php

    $dbhost = 'localhost';
    $dbuser = 'root';
    $dbpass = '1234';
    $dbname = 'sessions';

    mysql_connect($dbhost, $dbuser, $dbpass) or die("Could not connect: ".mysql_error());
    mysql_select_db($dbname) or die(mysql_error());

    ?>

    what should i put in my conf so that i can just call it using include . what else should i put on it? response is needed badly. im just playing with script today and preparing for my senior project hopefully next year.:confused:
     
    chinhelhas, Oct 18, 2009 IP
  2. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You include that file using
    include('conf.php');

    in the script that needs it. You don't actually need to do anything to that file unless your username, password and/or database name are incorrect
     
    JAY6390, Oct 18, 2009 IP
  3. spc

    spc Well-Known Member

    Messages:
    136
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    125
    #3
    Pu the below codes in a file named db.php

    
    <?php
    
    $dbhost = 'localhost';
    $dbuser = 'root';
    $dbpass = '1234';
    $dbname = 'sessions';
    
    mysql_connect($dbhost, $dbuser, $dbpass) or die("Could not connect: ".mysql_error());
    mysql_select_db($dbname) or die(mysql_error());
    
    ?>
    
    Code (markup):
    I guess your conf.php contains several settings.
    Now in your conf.php you can simply call this using the following line:
    include('db.php');

    If you have other fuctions on conf.php based on database, you should include the db.php on top portion.
     
    spc, Oct 18, 2009 IP