Simple PHP - MySQL Database Connection string

Collapse

Unconfigured Ad Widget

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Shane
    Senior Member
    • Jun 2006
    • 264

    Simple PHP - MySQL Database Connection string

    Hello All,

    In order to connect MySQL database from PHP script one can use bellow mentioned sample script:

    <?
    // Connect to the database
    mysql_connect ('localhost', 'database Username', 'database password') ;
    mysql_select_db ('database name');
    ?>
    Connected successfully

    Thanks,

    Shane G.
    AccuWebHosting.Com
  • Shane
    Senior Member
    • Jun 2006
    • 264

    #2
    AccuWeb.Cloud
    Re: Simple PHP - MySQL Database Connection string

    Sample Code: 2

    <?php
    $link = mysql_connect('<server>', '<username>', '<password>');
    if (!$link) {
    die('Could not connect: ' . mysql_error());
    }
    echo 'Connected successfully';
    mysql_select_db(<database>);
    ?>

    Thanks,

    Shane G.
    AccuWebHosting.Com
    Last edited by admin; 08-04-2015, 08:29 AM.

    Comment

    Working...
    X