1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Using pre-existing database for use with php script.

Discussion in 'MySQL' started by fluffedup, Nov 22, 2009.

  1. #1
    Ive set up AJAX Chat blueimp.net/ajax/

    And im trying to interegate the users from a pre existing online games website so they can log in with their credentials into AJAX Chat.

    The default users are put in a users.php (in the code below)

    <?php
    /*
     * @package AJAX_Chat
     * @author Sebastian Tschan
     * @copyright (c) Sebastian Tschan
     * @license GNU Affero General Public License
     * @link blueimp.net/ajax/
     */
    
    // List containing the registered chat users:
    $users = array();
    
    // Default guest user (don't delete this one):
    $users[0] = array();
    $users[0]['userRole'] = AJAX_CHAT_GUEST;
    $users[0]['userName'] = null;
    $users[0]['password'] = null;
    $users[0]['channels'] = array(0);
    
    // Sample admin user:
    $users[1] = array();
    $users[1]['userRole'] = AJAX_CHAT_ADMIN;
    $users[1]['userName'] = 'admin';
    $users[1]['password'] = 'admin';
    $users[1]['channels'] = array(0,1);
    
    // Sample moderator user:
    $users[2] = array();
    $users[2]['userRole'] = AJAX_CHAT_MODERATOR;
    $users[2]['userName'] = 'moderator';
    $users[2]['password'] = 'mod';
    $users[2]['channels'] = array(0,1);
    
    // Sample registered user:
    $users[3] = array();
    $users[3]['userRole'] = AJAX_CHAT_USER;
    $users[3]['userName'] = 'user';
    $users[3]['password'] = 'u';
    $users[3]['channels'] = array(0,1);
    ?>
    Code (markup):
    But i want to make it so it reads the username from a mysql database "ava_users --> username" and the password "ava_users --> password).


    Start of the MYSQL config.php - ive set up all the values but taken them out since its posted online.
    <?php
    /*
     * @package AJAX_Chat
     * @author Sebastian Tschan
     * @copyright (c) Sebastian Tschan
     * @license GNU Affero General Public License
     * @link blueimp.net/ajax/
     */
    
    // Define AJAX Chat user roles:
    define('AJAX_CHAT_CHATBOT',        4);
    define('AJAX_CHAT_ADMIN',        3);
    define('AJAX_CHAT_MODERATOR',    2);
    define('AJAX_CHAT_USER',        1);
    define('AJAX_CHAT_GUEST',        0);
    
    // AJAX Chat config parameters:
    $config = array();
    
    // Database connection values:
    $config['dbConnection'] = array();
    // Database hostname:
    $config['dbConnection']['host'] = 'host';
    // Database username:
    $config['dbConnection']['user'] = 'user';
    // Database password:
    $config['dbConnection']['pass'] = 'pass';
    // Database name:
    $config['dbConnection']['name'] = 'name';
    // Database type:
    $config['dbConnection']['type'] = 'type';
    // Database link:
    $config['dbConnection']['link'] = null;
    
    Code (markup):
    Can anyone help me to make it read from the database, Thanks.

    note: it uses mysql to log what ips are logged onto chat.
     
    Last edited: Nov 22, 2009
    fluffedup, Nov 22, 2009 IP
  2. bhagwant.banger

    bhagwant.banger Active Member

    Messages:
    99
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    60
    #2
    Add a role field to your existing users table in the database

    Then fetch the user details from there and put in this variable
     
    bhagwant.banger, Nov 28, 2009 IP
  3. James.M.Ayling

    James.M.Ayling Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Put in what variable???
     
    James.M.Ayling, Dec 18, 2012 IP