1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Quick help DB.PHP

Discussion in 'General Programming Chat' started by moneyplox, Dec 2, 2012.

  1. moneyplox

    moneyplox Registered Member

    Joined:
    Nov 18, 2012
    Messages:
    52
    Likes Received:
    1
    Code:
    <?php
    
        define('HOST', 'localhost');
    
        define('USER', '');
    
        define('PASS', '');
    
        define('DBNAME', '');
    
        $link = mysql_connect(HOST, USER, PASS);
    
        mysql_select_db(DBNAME, $link);
    
    ?>
    


    SKYPE: I7UP37T come helpahh fella outtt?
     
    Last edited by a moderator: Dec 3, 2012
  2. ikstob

    ikstob Junior Member

    Joined:
    Nov 12, 2012
    Messages:
    147
    Likes Received:
    129
    Location:
    ikstob.com
    Home Page:
    Well for starters, what's the problem? you should have your username/password/dbname filled otherwise the code above is just going to do nothing but throw PHP errors.

    PHP:
    <?php
    define
    ('HOST''localhost');
    define('USER''mydbuser');
    define('PASS''mydbpass');
    define('DBNAME''mydb');
    $link mysql_connect(HOSTUSERPASS);
    if (!
    $link) {
        die(
    'Could not connect: ' mysql_error());
    }
    mysql_select_db(DBNAME$link);
    ?>
    There are alternative ways to initialise MySQL documented on the PHP website:


    Code:
    hxxp://php.net/manual/en/mysqlinfo.api.choosing.php
     
    Last edited: Dec 3, 2012