Announcement

Collapse
No announcement yet.

Simple PHP - MySQL Database Connection string

Collapse

Ads on showthread pages

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Simple PHP - MySQL Database Connection string

    WordPress Hosting on SSD Servers
    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

  • #2
    ASP.Net Hosting starts @ $3.18/Mo.
    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, 09:29 AM.

    Comment

    Working...
    X
    Sign up for a News Letter Click here to sign up