Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    May 2003
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I'm looking for a PHP config.php guide

    I have a site that connects to a database on multiple pages and displays different data from different tables of that database. Right now, I have a $dbcnx command on every page, this is a little bit of a hassle. I'd like to create a config.php page that my front end pages will call.

    How would I go about doing this? I cannot seem to find a guide. Thanks in advance.
    Need tech support? Are you a techie?
    Then check out TechieHQ - Your Tech Support HeadQuarters

  • #2
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    create a file called config.php, put everything you want to be global inside of it, then in any page you want that information you just do
    PHP Code:
    include 'config.php'
    you can read about it here..
    http://us3.php.net/include/

  • #3
    New Coder
    Join Date
    May 2003
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've just specified in the index file to include the config page
    PHP Code:
    <? include('includes/config.php'); ?>
    and in the config
    PHP Code:
    // ****** DATABASE TYPE ******
    $config['Database']['dbtype'] = 'mysql';

    // ****** DATABASE NAME ******
    $config['Database']['dbname'] = 'db';

    // ****** MASTER DATABASE SERVER NAME AND PORT ******
    $config['MasterServer']['servername'] = 'localhost';
    $config['MasterServer']['port'] = 3306;

    // ****** MASTER DATABASE USERNAME & PASSWORD ******
    $config['MasterServer']['username'] = 'x';
    $config['MasterServer']['password'] = 'x'
    But, when I load index.php the table does not load. This is the code that pulls the table on index:
    PHP Code:
    // Request the text of all the info
                
    $result = @mysql_query('SELECT * FROM wanted');

             if (!
    $result) {
                   exit(
    '<p>Error performing query: ' mysql_error() . '</p>');
             }
             
    // Display the text of each game in a row
             
    while ($row mysql_fetch_array($result)) {
             echo 
    '' $row['title'] . ' (<em>' $row['system'] . '</em>)<br />';
            }
               
    ?> 
    Need tech support? Are you a techie?
    Then check out TechieHQ - Your Tech Support HeadQuarters

  • #4
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    you still need to have the connection and db-selects somewhere...

  • #5
    New Coder
    Join Date
    May 2003
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I read through the guide but it doesn't say how to do that.
    Need tech support? Are you a techie?
    Then check out TechieHQ - Your Tech Support HeadQuarters

  • #6
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    call mysql_connect() in your config.php


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •